[Python-Dev] Inconsistent script/console behaviour

Fernando Perez fperez.net at gmail.com
Sun Dec 18 08:46:48 CET 2011


On Fri, 23 Sep 2011 16:32:30 -0700, Guido van Rossum wrote:

> You can't fix this without completely changing the way the interactive
> console treats blank lines. None that it's not just that a blank line is
> required after a function definition -- you also *can't* have a blank
> line *inside* a function definition.
> 
> The interactive console is optimized for people entering code by typing,
> not by copying and pasting large gobs of text.
> 
> If you think you can have it both, show us the code.

Apology for the advertising, but if the OP is really interested in that 
kind of behavior, then instead of asking for making the default shell more 
complex, he can use ipython which supports what he's looking for:

In [5]: def some():
   ...:   print 'xxx'
   ...: some()
   ...: 
xxx

and even blank lines inside functions (albeit only in certain locations):

In [6]: def some():
   ...: 
   ...:   print 'xxx'
   ...: some()
   ...: 
xxx


Now, the dances we have to do in ipython to achieve that are much more 
complex than what would be reasonable to have in the default '>>>' python 
shell, which should remain simple, light and robust.  But ipython is a 
simple install for someone who wants fancier features for interactive work.

Cheers,

f



More information about the Python-Dev mailing list