Update December 2014: This post is now somewhat outdated, please see the github repo for more up to date information.
Can’t sleep. Write blog post.
I used to spend a lot of time using a Python REPL as a calculator, copying and pasting values back and forth between the REPL and Calculator.app, cursing, hitting ctrl-a, typing
hex(, hitting ctrl-e, and typing
). I thought “THERE’S GOT TO BE A BETTER WAY”. Now there is.
Calculon - A terminal-based programmer’s calculator endowed with unholy acting talent by the Robot Devil.
Calculon is basically a curses window jammed on top of a Python REPL (
bpython initially). Any code you type into the REPL will be executed as usual, with any numeric values displayed in the interface at the top in a variety of bases and formats. There are a couple of differences to the basic REPL:
If the code begins with an operator the line will be prepended with the last result, allowing the user to do something like this:
>>> 1234 1234 >>> <<1 2468
If the code is empty (ie. the user just hits enter), the last operation will be re-evaluated:
>>> 4936 >>> 9872 >>> 19744 >>>
There are functions called
unwatch()exposed, allowing the user to track variables in the main display (as per the screen capture above).
Calculon also supports configurable bit length and display width for the binary display, and left/right alignment:
Check it out on my github.
There are a few things that I (and my pal richo) plan to do to it in the near future: