Trying to understand Python objects
Robert Kern
robert.kern at gmail.com
Tue Nov 21 20:31:47 EST 2006
Ben Finney wrote:
> Or, the attributes are added to a specific instance (often in the
> initialisation method) so that each instance has a separate attribute
> with the same name::
>
> class Point(object):
> spam = 4
> def __init__(self):
> eggs = 2
There's a typo there. For the sake of not confusing the OP, this is correct:
class Point(object):
spam = 4
def __init__(self):
self.eggs = 2
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list