[IPython-dev] cell magics
Jason Grout
jason-sage at creativetrax.com
Sat Feb 16 20:52:24 EST 2013
On 2/16/13 7:35 PM, Thomas Kluyver wrote:
> On 17 February 2013 01:26, Jason Grout <jason-sage at creativetrax.com
> <mailto:jason-sage at creativetrax.com>> wrote:
>
> If you were going to use the name and the value, it would make sense
> to do:
>
> %R(input=['myvar'])
>
>
> Yep, that's functionally equivalent to what we do at present.
>
> or even
>
> %R(input='myvar')
>
>
> The list was to allow for multiple variables. You could have a special
> cased isinstance(input, str), but it's a bit unpythonic.
>
I see this syntax fairly often:
%R(input='myvar,othervar,thirdvar')
or
%R(input='myvar othervar thirdvar')
In fact, I got the code to parse that from the python library (IIRC):
input.replace(',', ' ').split()
So you could support:
* a string, variables delimited by commas or whitespace
* a list of strings
* a dictionary if you wanted to specify the R names
You could also do something like:
%R(myvar=myvar, othervar=othervar)
That's probably the most pythonic.
Thanks,
Jason
More information about the IPython-dev
mailing list