[IPython-dev] line magic in middle of line

Kyle Rawlins rawlins at gmail.com
Wed Dec 24 16:52:19 EST 2014


Hi all,
To my surprise I just noticed that assignment of a line magic that returns something to a variable works.  That is, I have a line magic I’ve written called `te` that parses something and returns a python object, and code like the following (specific to this magic, sorry) seems to do exactly what I would’ve hoped (but didn’t expect).

	x = %te x_e

Is this documented anywhere / actually supported behavior?  Under what conditions can line magics be mixed with python code?  Some rudimentary testing suggests that this might be specific to statements.  It is actually super useful to me that this works, but I couldn’t find any documentation that talked about this (or even any built in magics where this behavior would make much sense), so it would be helpful to know the limits.

Happy holidays,
-kyle

-- 
Kyle Rawlins
http://sites.krieger.jhu.edu/rawlins/
Department of Cognitive Science
Johns Hopkins University

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20141224/7b896a61/attachment.html>


More information about the IPython-dev mailing list