Accessing class variable at class creation time
esleben at gmail.com
Sat Sep 24 12:09:37 CEST 2005
That doesn't really give him a way of using the class variable inside a method.
2005/9/24, Benji York <benji at benjiyork.com>:
> Carlos wrote:
> > Hi!
> > class A:
> > X = 2
> > def F():
> > print A.X
> > F()
> > The above fails because the name A is not
> > yet at global scope when the reference A.X
> > is reached. Is there any way to refer to A.X
> > without making explicit use of the name 'A'?
> How about this:
> >>> class A:
> ... X = 2
> ... print X
> Benji York
More information about the Python-list