Message192813
| Author |
Olivier.Gagnon |
| Recipients |
Olivier.Gagnon, eric.snow, madison.may, rhettinger, serhiy.storchaka, vajrasky |
| Date |
2013年07月10日.14:28:35 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1373466515.3.0.121712462561.issue18352@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
The dictionary and the set do not give the freedom to add dynamic attributes to them. I agree that the Counter should have the same behaviour.
However, this will raise the same bug when we inherit from a Counter object.
>>> class mylist(list): pass
...
>>> l = mylist()
>>> l.foo = "bar"
>>> c = copy.deepcopy(l)
>>> print(c.foo) # prints bar
>>> class myCounter(Counter): pass
...
>>> original = myCounter()
>>> original.foo = "bar"
>>> c = copy.deepcopy(original)
>>> c.foo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'myCounter' object has no attribute 'foo'
The reduction function should still copy every dynamic attribute of the object. |
|