[Tutor] class variables

Nick Lunt nick at javacat.f2s.com
Wed Jun 23 15:40:09 EDT 2004


Just replying to my own email :)

I sent this about 3 days ago, and it's only just been received on the list,
after being forwarded by the tutor bouncer, what gives there ?

Nick.


-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org]On
Behalf Of Nick Lunt
Sent: 17 June 2004 23:42
To: Tutor
Subject: [Tutor] class variables


Hi folks,

Im making my way through the book 'Learning Python 2nd Edition'. I
understand classes but I have a question.
Take the following for example -

class beer:
    def __init__(self):
       self.make = 'murphys'
       cans = 4

There's several examples I've seen where 'self.var' isn't used, just
'var' is, as in 'cans' above.
I know that each instance of 'beer' will have its own value for 'make'
but what is the use of 'cans' without using self ?

Any pointers in the right direction happily received :)

Regards
Nick.



_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor




More information about the Tutor mailing list