member functions in a class
Gary Herron
gherron at islandtraining.com
Thu Sep 18 03:11:41 EDT 2008
Karl Kobata wrote:
>
> I am new to python and am wondering. When I create a class, with ‘def’
> functions and if this class is instantiated say 50 times. Does this
> mean that all the ‘def’ functions code within the class is duplicated
> for each instance?
>
> Can someone give me a short and simple answer as to what happens in
> python?
>
> Thanks
>
No code is duplicated. 50 "objects" are created. Each object has its own
copy of the data attributes, and a reference to the (one and only) class
object where the method attributes are located.
That's a short answer. Perhaps too short?
Gary Herron
> ------------------------------------------------------------------------
>
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list