[IPython-dev] Cell Magic names
MinRK
benjaminrk at gmail.com
Fri Jun 1 23:58:34 EDT 2012
I was playing with my shebang magic, and I decided to test something evil:
@cell_magic('#!')
def shebang(self, line, cell):
"""Run a cell via a shell command
The `%%shebang` line is like the #! line, specifying a program
(bash, perl, ruby, etc.)
"""
p = Popen(line, stdout=PIPE, stderr=PIPE, stdin=PIPE)
out,err = p.communicate(cell)
print(out, end='')
print(err, file=sys.stderr, end='')
Which actually lets me do:
%%#! bash
for i in 1 2 3; do
echo $i
done
I presume we don't want that to actually work, right? Kinda fun, though.
-MinRK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20120601/c715b059/attachment.html>
More information about the IPython-dev
mailing list