Thats a good pointer to what is going on. Thank you Bas.

I am familiar with error such as

x=1
def foo():
    x = 2
    def erm():
        print(x)
        x=3
    erm()
foo()
UnboundLocalError: local variable 'x' referenced before assignment.

It seems a bit different for classes (below), as it jumps out to get the
value from the global name space, where it didn't for functions (above).

x=1
def foo():
    x = 2
    class erm():
        print(x)
        x = 3
foo()      # This evaluates == 1

But you certainly have explained why  "NameError: name 'third' is not
defined" occurs.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to