[IPython-User] iPython notebook and statements that span multiple lines

Will Furnass will@thearete.co...
Mon Nov 12 05:09:58 CST 2012


> On 12 November 2012 10:48, William Furnass <will@thearete.co.uk> wrote:
> 
>> %timeit x = [1,
>>
>>              2,
>>
>>              3]
>>
>> IndentationError: unexpected indent
>>
>> Is this a bug or am I missing something obvious here?
>>

On Mon, 12 Nov 2012 10:54:46 +0000, Thomas Kluyver wrote:
>
> I guess it's not exactly obvious, but you can't (yet) split a line magic
> over several lines. You'll need to use a cell magic, like this:
> 
> %%timeit x = [1,
>      2, 3]

Ah, thanks.  Would it not make more sense for the line-level magic 
functions to continue parsing lines until all parentheses have been 
matched i.e. only operate on one or more complete statements?

Cheers,

Will




More information about the IPython-User mailing list