Class Variable Question

Fredrik Lundh fredrik at pythonware.com
Mon Apr 9 13:05:55 EDT 2001


Romuald Texier wrote:
> Robert Johnson wrote:
>
> > ClassObject.var1=5
>
> > Would this create a variable "var1" inside the class even though the
> > creator of the class never intended it to be there
>
> Not exactly: the new variable is not created inside the class but just in
> the _instance_. The class definition and other instances are left untouched.

depends on what "ClassObject" is, of course -- if it is a class
object (i.e. an object created by a class statement), robert's
exactly right.

Cheers /F





More information about the Python-list mailing list