Skip to content

Instantly share code, notes, and snippets.

@sevko sevko/README.md
Last active Aug 29, 2015

Embed
What would you like to do?
Parallel versions of bpython for Python 2 and 3.

bpython+

bpython+ is a thin wrapper around the bpython interpreter, which allows the user to specify whether it should be executed with version 2 or 3 of the Python interpreter; the implementation is practically identical to that of pylint+.

requirements

You must have:

  • python2 in your $PATH
  • python3 in your $PATH
  • bpython installed (via pip, and not from your package manager) for Python 2
  • pylint installed (via pip3, and not from your package manager) for Python 3

use

Place bpython+ somewhere in your $PATH, and make sure that it has executable permissions. Then:

bpython+ 2|3 [BPYTHON_ARGS]

For instance:

$ bpython+ 2
>>> import sys
>>> sys.version_info
sys.version_info(major=2, minor=7, micro=6, releaselevel='final', serial=0)

$ bpython+ 3
>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=4, micro=0, releaselevel='final', serial=0)
#! /usr/bin/env bash
# Description:
# A wrapper around bpython that allows the user to specify whether it should
# be executed with version 2 or 3 of the Python interpreter.
#
# Use:
# bpython+ PYTHON_VERSION [BPYTHON_ARGS]
#
# PYTHON_VERSION: Either 2 or 3, for version 2/3 of the Python interpreter.
# BPYTHON_ARGS: Argument to pass on to bpython.
python_interpreter="python${1}"
bpython_args="${@:2}"
bpython_import=$(cat << PYTHON
import sys
import pkg_resources
__requires__ = "bpython"
sys.exit(
pkg_resources.load_entry_point("bpython", "console_scripts", "bpython")()
)
PYTHON
)
$python_interpreter -c "$bpython_import" $bpython_args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.