[IPython-dev] cell magics

Thomas Kluyver takowl at gmail.com
Sat Feb 16 19:38:24 EST 2013


On 17 February 2013 00:14, Jason Grout <jason-sage at creativetrax.com> wrote:

> Cool.  I didn't know that.  But if k was a list (for some other
> parameter), and you were trying to sub it in, you'd have to convert the
> list to a string, then convert it back in the decorator.  That's a
> little silly.
>

In theory, but I don't think we've ever had such a case. The %%R magic has
something roughly similar - you can pass in variables including arrays, like

%%R -i myvar
code...

In that case, the magic looks in the namespaces for 'myvar', so it doesn't
have to be converted to a string and back. Arguably you could pull the
variable in more elegantly with your proposal, something like:

%R(input=[myvar])
code

But we also use the name to assign the converted variable to in R, so you'd
need to provide that separately:

%R(input={'myvar':myvar})
code

That is slightly more flexible, but most of the time it's going to involve
unnecessary repetition, in addition to the extra punctuation.

Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20130217/ff6a2caa/attachment.html>


More information about the IPython-dev mailing list