Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Traceback (most recent call last):
- File "bar.py", line 10, in <module>
- pickle.loads(pickle.dumps(foo))
- TypeError: __new__() takes 1 positional argument but 3 were given
- from collections import namedtuple
- import pickle
- class Foo(namedtuple("_Foo", ["a", "b"])):
- def __new__(cls, *args, **kwargs):
- self = super().__new__(cls, *args, **kwargs)
- # some custom code
- return self
- foo = Foo(a=1, b=2)
- pickle.loads(pickle.dumps(foo))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement