Why no lexical scoping for a method within a class?

r rt8396 at gmail.com
Wed Dec 17 14:23:49 EST 2008


On Dec 17, 12:20 pm, walterbyrd <walterb... at iname.com> wrote:
> On Dec 17, 10:00 am, r <rt8... at gmail.com> wrote:
>
> > When writing
> > procedural code how would you like it if vars inside functions were
> > automatically global. Your code with be blowing chunks in no time.
>
> That was my point - I consider python's ordinary use of lexical
> scoping to be a good thing, and I was wondering why this "good thing"
> was not used in classes, as well as outside of classes.

The whole point for even writing a class is for shared attributes.
Write procedural code if you don't like classes. When ever you see
self.var think of it as Class.instance(var)... makes total sense to
me? Obliviously you have not done much procedural coding or you would
know why this HAS to be. sorry if i sound rude.



More information about the Python-list mailing list