Skip to content

Instantly share code, notes, and snippets.

@13rac1
Last active December 15, 2015 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 13rac1/ad95acfd806098e75e65 to your computer and use it in GitHub Desktop.
Save 13rac1/ad95acfd806098e75e65 to your computer and use it in GitHub Desktop.
Using Python 3 as a screen-logging command-line calculator
#!/usr/bin/env python3
# Save this in your ~/bin as `cpy` and chmod +x
import code
import readline
import rlcompleter
# Directly import all the math functions
from math import *
print("Interactive Python 3 with 'from math import *'")
vars = globals()
vars.update(locals())
readline.set_completer(rlcompleter.Completer(vars).complete)
readline.parse_and_bind("tab: complete")
shell = code.InteractiveConsole(vars)
shell.interact()
@13rac1
Copy link
Author

13rac1 commented Dec 15, 2015

List of functions available in math: https://docs.python.org/3/library/math.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment