[Python-Dev] Scoping (corner cases)

Ka-Ping Yee ping@lfw.org
Sat, 17 Mar 2001 14:00:22 -0800 (PST)


Hey there.

What's going on here?

    Python 2.1b1 (#15, Mar 16 2001, 04:31:43) 
    [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
    Type "copyright", "credits" or "license" for more information.
    >>> x = 1
    >>> class Foo:
    ...     print x
    ... 
    1
    >>> class Foo:  
    ...     print x
    ...     x = 1
    ... 
    1
    >>> class Foo:
    ...     print x
    ...     x = 2
    ...     print x
    ... 
    1
    2
    >>> x
    1

Can we come up with a consistent story on class scopes for 2.1?



-- ?!ng