None weirdness

Jeff Epler jepler at unpythonic.net
Mon Dec 2 09:21:54 EST 2002


Ian,
If you assign to a name in a function, and do not give a "global"
delcaration, then the name is assumed to be local.

But in
    def main():
        a = None
        None = 1
there has been no local binding for the name "None" created by the time
the statement 'a = None' is being executed.

This has nothing to do with 'None', either.  You'll get the same error
with

    x = "spam" * 1000

    def f():
        a = x
        x = 1

    f()

Jeff




More information about the Python-list mailing list