Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A terminal-based programmer's calculator endowed with unholy acting talent by the Robot Devil
branch: master


A terminal-based programmer's calculator

I haven't found many decent programmer's calculators for Mac and I spend a fair bit of time copying and pasting between and a Python REPL, so I figured I'd have a go at writing a quick terminal-based calculator in Python. The result is Calculon.

Calculon is a programmer's calculator based on an embedded Python REPL. It's split into two components - the display and the REPL - each of which are run in a separate terminal. There are two options for the REPL - either the embedded Python REPL (based on the Python code module, or an instance of bpython.

Here is Calculon running on top of bpython in two panes of an iTerm window:

calculon example

And in a wider window:

calculon example2

And here is Calculon running with the embedded REPL, again using iTerm panes:

calculon example3


Calculon requires the Pyro4, blessings and rl modules. They will be automatically installed by the script.

To use bpython as the REPL you will obviously have to have bpython installed.


A standard setuptools script is included.

# python install


An example config (example.cfg) is included with the source. Copy it to ~/.calculon/config and edit it if you like, otherwise the defaults in the defaults.cfg will be used.


To run the display:

$ calculon display

To run the embedded REPL:

$ calculon console

Or, to connect to the display from within a bpython instance:

$ bpython
>>> import calculon.load

From here, any Python code entered into the REPL that results in a numeric value will be rendered in the display. For example:

>>> 1234 + 1234

2468 will be rendered in the display.

Calculon adds some hackery to the REPL for watching variables. Calling watch <expr> will add the given expression to a list of expressions that are tracked and updated every time they change. For example:

>>> watch a
>>> watch b
>>> watch a + b

Now when these variables are updated:

>>> a = 1234
>>> b = 1234

Their values will be tracked and the expressions reevaluated. Expressions can be removed from this display with the unwatch keyword:

>>> unwatch 0

Where 0 is the ID displayed at the end (or beginning, when right aligned) of the line.

Calculon now has support to connect to voltron and inspect register state. If you have the most recent version of calculon and voltron, and voltron is running, calculon will connect to it at startup. Calculon can manually connect and disconnect from voltron as follows:

>>> V.connect()
Connected to voltron
>>> V.disconnect()
Disconnected from voltron

When connected to voltron, calculon can inspect registers:


Or memory:

>>> V[V.rbp]
>>> V[V.rbp:V.rbp + 32]

Values from Voltron can now be included in watch expressions:

>>> watch


richo deserves many beers for his efforts

Something went wrong with that request. Please try again.