manavan.j at gmail.com
Wed Jun 10 15:34:56 EDT 2009
Since the real world objects often needs to be deleted even if they
have some reference from some other object, I am going to use this
approach to better model this situation, by cleaning up the attributes
and assigning self.__class__ to a different class.
Any comment on this approach.
def __init__(self, *args):
self.attrs = args
self.__class__ = Deleted
>>> a = RealWorldObj(1,2,3)
>>> print a.attrs
(1, 2, 3)
<__main__.Deleted object at 0x893ae2c>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Deleted' object has no attribute 'attrs'
More information about the Python-list