Last night I noticed that Python does not resolve name in "def" during import,
as C does in the compile/link stage, it was deferred until it was referenced
(i.e. codes was executed). That's OK for Anyway codes has to be debugged sooner
or later. I just have to get used to this style.
But check these codes, it seems not.
-------
x = 1 # a global variable
print(x)
class Test:
x = 4 # a class attribute
print(x)
def func(self):
print(x)
x1 = Test()
x1.x = 41 # a instance's attribute
x1.func() # it's 1 but 41 was expect:-(
--------
--Jach
--
https://mail.python.org/mailman/listinfo/python-list