Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. Traceback (most recent call last):
  2. File "bar.py", line 10, in <module>
  3. pickle.loads(pickle.dumps(foo))
  4. TypeError: __new__() takes 1 positional argument but 3 were given
  5.  
  6. from collections import namedtuple
  7. import pickle
  8.  
  9. class Foo(namedtuple("_Foo", ["a", "b"])):
  10. def __new__(cls, *args, **kwargs):
  11. self = super().__new__(cls, *args, **kwargs)
  12. # some custom code
  13. return self
  14.  
  15. foo = Foo(a=1, b=2)
  16. pickle.loads(pickle.dumps(foo))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement