With four lines of text you can add a command to do this:
% ev "sqrt(2)"
1.4142135623730951
Below is the code — just put it in your personal bin or script directory:
#! /usr/bin/env python3
import sys
from math import *
print(eval(sys.argv[1]))
This is useful for quick one-line computations. For more, it’s of course better to jump into the Python interpreter — or sage. If you have any Python functions that you want to use in this way, just add an import statement to the above. For example, in my PYTHONPATH directory, I have a file mathtools.py which defines a function factor.
Thus I can do this:
% ev "factor(123456789)"
[3, 3, 3607, 3803]
provided that I add the line
from mathtools import *
to the code for ev.
zipTimer: an iPod/iPhone app for pacing piano practice, cooking, workouts, you name it.