[Python-Dev] __dynamic__ attribute

James_Althoff@i2.com James_Althoff@i2.com
Tue, 14 Aug 2001 15:23:22 -0700

Given that  __dynamic__ will be part of Python in 2.2 . . .

Is it worth considering the possibility of making it more granular (somehow
controlling separately the modification of attribute values versus the
addition or deletion of attributes, perhaps)?  Currently it controls the
changing of a class object in all ways (if set to 1 it makes the class
object immutable).  It seems to me there is a significant difference in
general usage between:

>>> class A(object):
...   __dynamic__ = 1
...   count = 0
...   def incr(myclass): myclass.count += 1
...   incr = classmethod(incr)
>>> A.count
>>> A.incr()
>>> A.count

which is a pretty common idiom in Java and C++ and other more dynamic
things like adding/deleting attributes (data and methods) on the fly.