Skip to content
Russell91 edited this page Jun 14, 2014 · 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`)'
5
py -c 'import numpy as np' 'np.linspace(0,1,6)'
0.0
0.2
0.4
0.6
0.8
1.0

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 '"'"'import matplotlib; matplotlib.use(`Agg`); import matplotlib.pyplot as plt'"'"' -C '"'"'plt.savefig("output.pdf")'"'"
py '[math.sin(x/10) for x in range(100)]' | pyplt -l 'plt.plot(l)'

Clone this wiki locally