newbie question on class vars
Sean 'Shaleh' Perry
shalehperry at attbi.com
Tue Oct 8 01:06:26 CEST 2002
On Monday 07 October 2002 15:46, JXSternChangeX2R wrote:
> Oops, come to think of it, I did mean it to be by instance.
> Tho my syntax question, remains.
then you want:
self.__myvar = 1
yes, you must use self (or whatever you call the variable). This is just the
way things are. You learn to prefer it after using Python for a while and
then going back to other languages.
if you place the variable as:
myvar = 1
def __init__(self): pass
then you are making the variable global to all instances of the class as I
demonstrated in my last mail.
More information about the Python-list