Question about accessing class-attributes.

Andrew Bennetts andrew-pythonlist at puzzling.org
Thu Apr 24 13:47:41 CEST 2003


On Thu, Apr 24, 2003 at 01:29:44PM +0200, Nikolai Kirsebom wrote:
> Given the following class hierarchy:
>       
> class A(object):
>       InstCount = 0
>       def __init__(self):
>               self.__class__.__dict__['InstCount'] += 1

A simpler way to do this line would be:

              self.__class__.InstCount += 1

-Andrew.






More information about the Python-list mailing list