nested scopes
Aahz Maruch
aahz at panix.com
Fri Feb 9 10:40:21 EST 2001
More information about the Python-list mailing list
Fri Feb 9 10:40:21 EST 2001
- Previous message (by thread): nested scopes
- Next message (by thread): nested scopes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <96059d$din$1 at news.mathworks.com>, Joshua Marshall <jmarshal at mathworks.com> wrote: > >Still this is a different issue than lexical scoping. Consider: > > class T: > def m(self): > print self.x > > T.x = 'foo' > > T().m() > >Here, T().m() prints "foo". Lexically, x is not defined in m's scope. >I believe it was a good decision to require going through self to >access class/object fields. Note that you don't necessarily want to go through self to access class fields. Here you're relying on the search through the class hierarchy to access T.x with self.x. (I'm pretty sure you know this, but I don't want any newcomers getting confused.) -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Actually, I've found that Usenet has helped a lot with my terror of social stupidity. Seeing people I really like and respect behave like idiots in public has been very beneficial." --Rachael Lininger
- Previous message (by thread): nested scopes
- Next message (by thread): nested scopes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list