__dynamic__ attribute

James_Althoff at i2.com James_Althoff at i2.com
Tue Aug 14 18:23:22 EDT 2001


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
0
>>> A.incr()
>>> A.count
1
>>>

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.

Jim






More information about the Python-list mailing list