[IPython-dev] Cell Magic names
Fri Jun 1 23:07:32 CDT 2012
On Fri, Jun 1, 2012 at 8:58 PM, MinRK <firstname.lastname@example.org> wrote:
> I was playing with my shebang magic, and I decided to test something evil:
> def shebang(self, line, cell):
> """Run a cell via a shell command
Oh, what fun, I love it! Actually, this is not that crazy considering
that we already have the `!foo` syntax. I guess the important
question is this: are the any constraints on the names of cell magics
at all? Will this mess up things somehow?
> 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
> I presume we don't want that to actually work, right? Kinda fun, though.
I think there are two questions:
* Will this actually break something?
* Is another name for this magic clearer?
> IPython-dev mailing list
Brian E. Granger
Cal Poly State University, San Luis Obispo
email@example.com and firstname.lastname@example.org
More information about the IPython-dev