Message160212
| Author |
mattofak |
| Recipients |
mattofak |
| Date |
2012年05月08日.16:48:00 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1336495681.08.0.928968758685.issue14756@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| 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 |
|