[IPython-dev] Re: Question about IPython behaviour

Fernando Perez Fernando.Perez at colorado.edu
Wed Jul 27 00:48:37 CDT 2005


Robert Kern wrote:
> Tzanko Matev wrote:
> 
>>Hi all,
>>
>>The prefilter() method turns strings consisting only of whitespace to
>>empty strings. This means that in IPython I cannot write the following
>>code:
>>
>>In[1]: if 1==1:
>>   ... ___print 1
>>   ... ___   
>>   ... ___print2
>>   ...
>>
>>(here I have replaced spaces with underscore). prefilter() will turn the
>>third line into an empty string and the interpreter will decide that the
>>block ends there. This differs from the behaviour of the standard
>>interpreter where the code would run as expected.  So is this a bug or a
>>feature? I think that empty lines should be allowed in the GUI.
> 
> 
> So code to a different interface like the one in notabene.executor. The 
> GUI decides when the input is complete, sends it whole to the 
> interpreter, and gets a response back.

I second Robert's suggestion.  The reason for ipython's behavior is partly to 
mimic the default '>>>' interpreter, partly because it's tricky to do 
otherwise in a line-oriented environment.  The default python shell simply 
uses the convention 'a single empty line signals the end of input'.  IPython 
inherits from code.InteractiveConsole, which maintains this behavior.

While not ideal, I think that's not terrible for a simple line-oriented system 
which doesn't really offer any serious multiline editing.  But now that we are 
migrating to a GUI, we should most certainly offer a way to have blank lines.

Cheers,

f




More information about the IPython-dev mailing list