class object's attribute is also the instance's attribute?

Oscar Benjamin oscar.j.benjamin at gmail.com
Thu Aug 30 08:52:43 EDT 2012


On Thu, 30 Aug 2012 05:34:51 -0700 (PDT), Marco Nawijn 
<nawijn at gmail.com> wrote:
> If you want attributes to be local to the instance, you have to 
define them in the __init__ section of the class like this:

> class A(object):
>    def __init__(self):
>         d = 'my attribute'

Except that in this case you'd need to do:
         self.d = 'my attribute'

Oscar




More information about the Python-list mailing list