Concerning classes (Newb question)
Erik Max Francis
max at alcyone.com
Mon Aug 2 13:50:55 EDT 2004
Cyrille Lavigne wrote:
> I'm very new to the art of programming and I just learn OOP
> in python. I want to know why the following bit of code crash.
> Code:
> class Exemple:
> def __init__(self):
> self.list=[]
> self.var1=3
>
> c=Exemple
> print c.list, c.var1
You're binding c to the class, not an instance. To create a new
instance, call the class:
c = Exemple()
--
__ Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ Everything's gonna be all right / Everything's gonna be okay
-- Sweetbox
More information about the Python-list
mailing list