Let say I have this class:
class A(object):
def __init__(self, one=None):
self.one = one
So every time you create A
object, you can assign one
attribute. But only the last object assigned not false value gets to keep it.
For example:
a = A('a')
b = A('b')
c = A()
print a
print b
print c
----
None
b
None
Now these objects are also actual records (rows) in database, so those could be accessed later.
What could be a good pattern (if there is) to set such attribute dynamically (unsetting attribute for older objects)?