Question about accessing class-attributes.
Nikolai Kirsebom
nikolai.kirsebom.NOJUNK at siemens.no
Fri Apr 25 10:50:15 EDT 2003
On Thu, 24 Apr 2003 13:29:44 +0200, Nikolai Kirsebom
<nikolai.kirsebom.NOJUNK at siemens.no> wrote:
>Given the following class hierarchy:
>
>class A(object):
> InstCount = 0
> def __init__(self):
> self.__class__.__dict__['InstCount'] += 1
>
>class B(A):
> InstCount = 0
>
>class C(A):
> InstCount = 0
>
>Is the syntax used for incrementing the class-attribute for every
>instanciation 'the way' it should be done ?
>
>Nikolai Kirsebom
>
>
Thanks for all the replies. Have to go back and start learning using
metaclasses....
Nikolai
More information about the Python-list
mailing list