Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44370
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <hexforge@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.022 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'referenced': 0.09; 'thats': 0.09; 'def': 0.12; 'assignment.': 0.16; 'evaluates': 0.16; 'foo()': 0.16; 'foo():': 0.16; 'jumps': 0.16; 'occurs.': 0.16; 'variable': 0.18; 'bit': 0.19; 'seems': 0.21; 'error': 0.23; 'certainly': 0.24; 'pointer': 0.24; 'message-id:@mail.gmail.com': 0.30; 'explained': 0.31; 'class': 0.32; 'classes': 0.35; 'but': 0.35; 'received:google.com': 0.35; "didn't": 0.36; 'skip:& 10': 0.38; 'thank': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'name': 0.63; 'such': 0.63; 'different': 0.65; 'subject:. ': 0.67 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=/wDJMhLQDwYClWafKj680Rcw7B+ffZcNkv/mCJZs4EA=; b=0ic/Hc3Nxti3RbqqVG/OvW5ijXpeFsF1Q2Q0Q3posZeZPUsQ7NeOQ2HAYDCg4/rjTw zvFieO2FHkb92W84YNTcxMt/nwJtt3La7mF7oCPrGJjpZW91rpqGuf9utdh0cXm3DBq3 MMhiyoC2d7fX6ygsy+LU70we7ZNWuerv5ukr/J8nvWlXsSkcgFzTGeSWFeANpU+FOGUj PIo44z0cSo3G9ry+2O/55srT7xEwSDAuCyF+QVCtO7LYwAOAGqHsUrKr5LBlJYb5v8F8 n5P51GzvuWgkzPiiIlqet2RCvWzkWCV0+CJYQjZHlJ9lTNkmWtdhBRC+oUoeh/1w/G9W hbMA== |
| MIME-Version | 1.0 |
| X-Received | by 10.43.114.8 with SMTP id ey8mr22920124icc.6.1366929473696; Thu, 25 Apr 2013 15:37:53 -0700 (PDT) |
| Date | Thu, 25 Apr 2013 23:37:53 +0100 |
| Subject | Re: baffled classes within a function namespace. Evaluation order. |
| From | Alastair Thompson <hexforge@gmail.com> |
| To | python-list@python.org |
| Content-Type | multipart/alternative; boundary=bcaec5171e1db67a4204db371155 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1072.1366930490.3114.python-list@python.org> (permalink) |
| Lines | 52 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1366930490 news.xs4all.nl 15973 [2001:888:2000:d::a6]:44066 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:44370 |
Show key headers only | View raw
[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