[Python-Dev] Inconsistent script/console behaviour

Georg Brandl g.brandl at gmx.net
Sat Sep 24 12:05:21 CEST 2011


You're right that in principle for function definitions there is no ambiguity.
But you also presented the downfall of that proposal: all multi-clause
statements will still need an explicit way of termination, and of course the
"pass" would be exceedingly ugly, not to mention much more confusing than the
current way.

Georg

Am 24.09.2011 11:53, schrieb Yuval Greenfield:
> Could you elaborate on what would be wrong if function definitions ended only
> after an explicitly less indented line? The only problem that comes to mind is
> global scope "if" statements that wouldn't execute when expected (we actually
> might need to terminate them with a dedented "pass").
> 
> On Sep 24, 2011 4:26 AM, "Georg Brandl" <g.brandl at gmx.net
> <mailto:g.brandl at gmx.net>> wrote:
>> Am 24.09.2011 01:32, schrieb Guido van Rossum:
>>> On Fri, Sep 23, 2011 at 4:25 PM, anatoly techtonik <techtonik at gmail.com
> <mailto:techtonik at gmail.com>> wrote:
>>>> Currently if you work in console and define a function and then
>>>> immediately call it - it will fail with SyntaxError.
>>>> For example, copy paste this completely valid Python script into console:
>>>>
>>>> def some():
>>>> print "XXX"
>>>> some()
>>>>
>>>> There is an issue for that that was just closed by Eric. However, I'd
>>>> like to know if there are people here that agree that if you paste a
>>>> valid Python script into console - it should work without changes.
>>>
>>> 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.
>>
>> While the former could be changed (I think), the latter certainly cannot.
>> So it's probably not worth changing established behavior.






More information about the Python-Dev mailing list