Message160212
When initializing a class with an empty dict() object as a default initializer, if it is not overridden, multiple instances of the class will share the dictionary. IE:
class test(object):
def __init__(self, obj=dict()):
self.obj = obj
a = test()
b = test()
Then id(a.obj) points to the same location as id(b.obj). The behaviour I would expect would be that a.obj and b.obj would be unique instances. |
|
Date |
User |
Action |
Args |
2012-05-08 16:48:01 | mattofak | set | recipients:
+ mattofak |
2012-05-08 16:48:01 | mattofak | set | messageid: <1336495681.08.0.928968758685.issue14756@psf.upfronthosting.co.za> |
2012-05-08 16:48:00 | mattofak | link | issue14756 messages |
2012-05-08 16:48:00 | mattofak | create | |
|