[IPython-dev] IPython-dev Digest, Vol 131, Issue 37

Kyle Rawlins rawlins at gmail.com
Fri Dec 26 18:00:29 EST 2014


On Dec 25, 2014, at 1:00 PM, ipython-dev-request at scipy.org wrote:
> Date: Wed, 24 Dec 2014 22:28:09 +0000
> From: Thomas Kluyver <takowl at gmail.com>
> Subject: Re: [IPython-dev] line magic in middle of line
> To: IPython developers list <ipython-dev at scipy.org>
> Message-ID:
> 	<CAOvn4qhVYeM5_Nys6RaZ2degweHu5r400ide6pmSuOGj_pHtXw at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
> 
> Hi Kyle,
> 
> On 24 December 2014 at 21:52, Kyle Rawlins <rawlins at gmail.com> wrote:
> 
>> Is this documented anywhere / actually supported behavior?  Under what
>> conditions can line magics be mixed with python code?
> 
> 
> It only works in simple assignments, and you can do it with both magics and
> !system escapes - the normal demo of that feature is to do "files = !ls".
> The timeit magic also returns a useful results object.
> 
> It is documented for system commands:
> http://ipython.org/ipython-doc/dev/interactive/tutorial.html#system-shell-commands
> http://ipython.org/ipython-doc/dev/interactive/reference.html#manual-capture-of-command-output
> 
> But I can't currently see anywhere where this is documented for magic
> functions.

Great, thanks, glad to hear this is intended!  I thought this might be pretty useful for people to know about, so I opened a small pull request updating the docs based on the example `files = %sx ls`, which I discovered does exactly the same thing as the above ! example.

Best,
-kyle



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




More information about the IPython-dev mailing list