Re: member functions in a class

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gary Herron

    Re: member functions in a class

    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
Working...