PEP 255: Simple Generators, Revised Posting

Bernhard Herzog bh at intevation.de
Sun Jun 24 15:22:32 EDT 2001


"Jeremy Hylton" <jeremy at alum.mit.edu> writes:

> This would be easy to fix in the case of yield for generators, except that
> I'm not sure it's easy to fix for names in general.  There are lots of other
> strange possibilities:
> 
> def f():
>     if 0:
>         exec foo
>     def g(y):
>         return x + y
> 
> Should this get a SyntaxError about the bare exec making resolution of free
> variable x ambiguous?

I'm not sure about this one. Since it's obvious even to the compiler
that the exec statement will never actually be executed, it seems OK to
me to simply ignore it, though.


> def g(x):
>     if 0:
>         global x
> 
> Should this get a SyntaxError about an argument being declared global?

IMO yes; especially, considering that the global statment is recognized
in e.g.

def g(x):
    if ():
        global x


  Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Sketch                                 http://sketch.sourceforge.net/
MapIt!                                               http://mapit.de/



More information about the Python-list mailing list