Variable Modifications in a class

Peter Hansen peter at engcorp.com
Tue Jun 3 13:34:30 EDT 2003


Greg Unrein wrote:
> 
> Mehta, Anish wrote:
> > def func(ab):
> >   b = ab()
> >   c = ab()
> >
> >   b.a = 5
> >   b.b = 10
> >
> >   c = b
> 
> This is your problem. c and b are the same object.

Clearer to say that c and b are *bound* to the same object.
They are not themselves the objects.  In Python terminology
they are "names", or variables if you like that term, but
in traditional terms they are more like pointers to the object
than they are like the object itself.




More information about the Python-list mailing list