[IPython-dev] Cell Magic names
Fri Jun 1 23:52:46 CDT 2012
On Fri, Jun 1, 2012 at 9:07 PM, Brian Granger <email@example.com> wrote:
> 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
> > @cell_magic('#!')
> > 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
> > done
> > 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?
I imagine we want magics to be identifiers, but I guess `%%...<space>` is
sufficiently well defined that there's no technical reason why any unicode
characters should be illegal.
* Is another name for this magic clearer?
I was just going to call it `%%shebang`, I think `%%#!` is a few too many
special characters in a row.
> > -MinRK
> > _______________________________________________
> > IPython-dev mailing list
> > IPythonemail@example.com
> > http://mail.scipy.org/mailman/listinfo/ipython-dev
> Brian E. Granger
> Cal Poly State University, San Luis Obispo
> firstname.lastname@example.org and email@example.com
> IPython-dev mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev