[issue29357] New NamedTuple syntax silently ignores method definitions
Ivan Levkivskyi
report at bugs.python.org
Tue Jan 24 03:41:54 EST 2017
Ivan Levkivskyi added the comment:
This has been already reported in https://github.com/python/typing/issues/352 and fixed in https://hg.python.org/cpython/rev/f100619e7137 and https://github.com/python/typing/pull/364
Now adding new methods works but overwriting existing special attributes raises AttributeError:
class A(NamedTuple):
x: int
def spam(self): # this works
...
def _fields(self): # this is an error (and also for __repr__ etc)
If you think that overwriting all special attributes should be allowed (or only some of them) then we could discuss this at python/typing tracker.
----------
nosy: +levkivskyi
resolution: -> duplicate
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29357>
_______________________________________
More information about the Python-bugs-list
mailing list