A very simple question
Ben Finney
bignose-hates-spam at and-benfinney-does-too.id.au
Thu Jul 31 21:01:22 EDT 2003
On Thu, 31 Jul 2003 17:13:36 -0800, Arnaldo Riquelme wrote:
> I'm getting familiar with Python and I have a simple question:
>
> class abc:
> x = 100
> y = 200
> z = 300
>
>
> ac = abc()
>
> Shouldn't I have a attribute named __dict__ for ac that contains a
> dictionary of all the variables?
No. The attributes x, y, and z are associated with the class, not any
particular instance. (As your experiment with abc.__dict__ shows.)
If you want attributes that are bound to a particular instance, set them
in the class's __init__() method.
--
\ "It ain't so much the things we don't know that get us in |
`\ trouble. It's the things we know that ain't so." -- Artemus |
_o__) Ward (1834-67), U.S. journalist |
Ben Finney <http://bignose.squidly.org/>
More information about the Python-list
mailing list