Instances?

Alex Martelli aleaxit at yahoo.com
Wed Aug 1 14:39:32 CEST 2001


"Angel Asencio" <asencio at mitre.org> wrote in message
news:3B671064.73902FDF at mitre.org...
> Original class:
>
> class Foo:
>     x = []
>     y = []
    ...
> class Foo:
>     def __init__(self):
>         self.x = []
>         self.y = []
    ...
>  So, does not putting data attributes inside the __init__ would
> make them the equivalent to class variables on smalltalk or
> static variables in Java?

Basically, yes.  The first version has x and y as attributes
of the class, shared by all instances; the second version has
them as separate attributes of each instance.


Alex






More information about the Python-list mailing list