forked from lowks/pythonpy
-
Notifications
You must be signed in to change notification settings - Fork 0
More Examples
Russell Stewart edited this page Mar 20, 2015
·
53 revisions
Pythonpy will automatically replace sharp quotes with single quotes before processing an expression:
py '`hello world`' hello world py '"ma`am"' ma'am
Run a statement as you would using python -c with py -c:
py -c 'a = 5; print(`a`)' a
Alternatively:
py -c 'a = 5' 'a' 5
The argument of (-c) will run before the expression. In the rarer case that you need to run a statement after the main expression, you can use the (-C) flag.
Plot data you have access to from the command line using the pyplt alias:
alias pyplt='py -c '"'"'matplotlib.use(`Agg`); from matplotlib import pyplot as plt'"'"' -C '"'"'plt.savefig("output.jpg")'"'"
py '[math.sin(x/10) for x in range(100)]' | pyplt -l 'plt.plot(l)'
Fig1. - output.jpg