[IPython-user] Remove leading blank?

Fernando Perez Fernando.Perez at colorado.edu
Fri Sep 15 14:04:47 CDT 2006

Bo Peng wrote:
> Hi, Fernando,
> I just downloaded ipython and but can not find one particular feature I 
> need. You may be interested in it. (Or is it already there?)
> I want to debug a big function so I define parameters in ipython. I then 
> want to paste lines from an editor to ipython, check if they work, and 
> make modifications if necessary. Maybe you have seen the problem: 
> indenting! Every time, I have to add an if 1: to allow my pasted code to 
> execute.
> Is it possible to automatically remove leading blanks/tabs from pasted 
> code? Since they will certainly lead to errors so this auto adjustment 
> will not hurt.

In [3]: cpaste
Pasting code; enter '--' alone on the line to stop.
:    print 'hi Bo'
:    print 'This code was indented in emacs...'
hi Bo
This code was indented in emacs...

In [4]:

Type cpaste? for details.



More information about the IPython-user mailing list