[Tutor] class question
Dave S
pythontut at pusspaws.net
Mon May 17 12:48:26 EDT 2004
I guess Im one of those guys for whom classes do not come easy !
class test:
a=1
b=2
def __init__(self):
self.c=5
self.e=6
def somedef(self):
self.f=7
self.g=8
In a class structure, you can use either a simple a=2 or self.a=2. OK
Ive read the text but am still not clear.
The self.a=2 tags this variable to the genrated instance via self ....
ok ... and appears to be a global variable.
So what happens with plain a=2.
What I am asking is when sould I use a=2 & when self.a=2 ?
Thanks in advance
Dave
More information about the Tutor
mailing list