import json from collections import namedtuple Emp = namedtuple('Emp', 'name age') Emp.tojson = json.dumps(Emp._asdict()) a = Emp('Luc', 10) print(a.tojson())
Standard input is empty
Standard output is empty
Traceback (most recent call last): File "./prog.py", line 6, in <module> TypeError: _asdict() missing 1 required positional argument: 'self'