[Tutor] class variables
nick at javacat.f2s.com
Thu Jun 24 18:37:47 EDT 2004
Thankyou chad. I replied to this yesterday but it has yet to appear on the
Thanks for your help.
There is definitely something wrong with the list at the moment.
Its now 2330 in the UK, Ill see what time this gets to the list.
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org]On
Behalf Of Chad Crabtree
Sent: 24 June 2004 06:13
To: tutor at python.org
Subject: Re: [Tutor] class variables
> class beer:
> def __init__(self):
> self.make = 'murphys'
> cans = 4
> There's several examples I've seen where 'self.var' isn't used,
> 'var' is, as in 'cans' above.
> I know that each instance of 'beer' will have its own value for
> but what is the use of 'cans' without using self ?
this troubled me at first and I'm not sure but I may have asked this
very question here.
self.var in this case means that it's a class variable available to
the instance. In this case 'cans' is a function variable only
available to things inside that function. just like this
I hope this helps.
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
Tutor maillist - Tutor at python.org
More information about the Tutor