Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44370
| Date | 2013-04-25 23:37 +0100 |
|---|---|
| Subject | Re: baffled classes within a function namespace. Evaluation order. |
| From | Alastair Thompson <hexforge@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1072.1366930490.3114.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
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.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: baffled classes within a function namespace. Evaluation order. Alastair Thompson <hexforge@gmail.com> - 2013-04-25 23:37 +0100
csiph-web