[IPython-user] cannot paste indented code

Fernando Perez Fernando.Perez at colorado.edu
Wed Jan 4 17:22:23 CST 2006


frank h. wrote:
> hello,
> i am new to ipython (using it on mac os x)
> 
> I cannot seem to be able to paste indented code
> below is the transcript of a session where I am trying to paste a
> print statement into ipython that has a tab in front of it.
> the same problem occurs when the print statement is preceeded with
> spaces. it also occurs independent of the editor i am using to copy
> from
> 
> the line I am pasting:
> 
>     print "ho"

Let me add something, I realized I was too quick in my original reply.

You can NOT paste code which STARTS indented, neither in ipython nor in the 
normal python shell.

 >>>     print 'hi'
   File "<stdin>", line 1
     print 'hi'
     ^
SyntaxError: invalid syntax


This is simply invalid python syntax, period.  You can find out more about the 
language from the python tutorial.

What ipython (as of 0.7.0) has is support for pasting tab-indented multiline 
input without getting confused.

Cheers,

f




More information about the IPython-user mailing list