[IPython-dev] cell magics

Brian Granger ellisonbg at gmail.com
Sun Feb 17 19:50:51 EST 2013


I apologize that I don't have much time to participate in this
discussion, but I will try to summarize my thoughts.

* I don't think that changing IPython's line/cell magic syntax is on
table right now.
* I think the syntax you are proposing has a leaky abstraction that
will come back to bite you:

By having the syntax 1/2 python and 1/2 unrestricted strings, you are
going to be continually forced to make decisions about which things go

Why not this:

%timeit() -n1 -r1 myfunction()

* I also think your proposed syntax completely misses the point of
magics - namely to allow non-python syntax for quick and easy
interactive usage.  If you are not doing that with magics, then why
not just use pure python and regular functions/classes with no "%" at
* I agree with the namespace pollution thoughts that Fernando mentioned.



On Sat, Feb 16, 2013 at 5:52 PM, Jason Grout
<jason-sage at creativetrax.com> wrote:
> 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
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu and ellisonbg at gmail.com

More information about the IPython-dev mailing list