[IPython-user] recalling indented blocks -- strange bug

Fernando Perez fperez.net@gmail....
Sun Jan 10 21:34:03 CST 2010

On Sun, Jan 10, 2010 at 7:04 PM, John Hunter <jdh2358@gmail.com> wrote:
> I am having a surprising problem on ubuntu karmic (9.10) 32bit using
> ipython 0.10 (same in the development branch BTW)   In the session
> below, I type::
> for i in  range(10):
>    print i
> relying on ipython to autoindent the print line for me -- this works
> fine.  But if I then "up arrow" to recall the entire "for" block, the
> block execution fails with an indentation error.  Something about
> recalling the block from history is causing it to lose the proper
> indentation.  This is something I do a lot (on other machines) and
> have not seen this so it may be platform/version specific.

It's this stupid problem:


Your options:

- disable autocall permanently

- start using the future print_function and print() everywhere (except
for single-lines, where autocall works for you)

Here, on dev-branch:

In [2]: for i in range(10):
    print i,
------> print(i,)
IndentationError: expected an indented block (<ipython console>, line 2)

In [4]: autocall 0
Automatic calling is: OFF

# now it's ok:
In [5]: for i in range(10):
    print i,
0 1 2 3 4 5 6 7 8 9

Since we'll have to get used to print() anyway, might as well do it early...



More information about the IPython-user mailing list