Serhiy Storchaka <[email protected]> added the comment:
In 2.7 namedtuple() takes four arguments.
namedtuple(typename, field_names, verbose=False, rename=False)
A sequence of field names should be passed as the second argument. In you case
you pass four argumens: 'a' as field names, 'b' as the verbose flag, and 'c' as
the rename flag. Since 'b' has true boolean value, namedtuple() outputs the
source used for generating a named tuple with a single field 'a'.
In Python 3.6+ verbose and rename are keyword-only parameters (see issue25628)
and this error can be caught earlier:
>>> sample = namedtuple('Name','a','b','c')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: namedtuple() takes 2 positional arguments but 4 were given
This change can't be backported to 2.7 for two reasons:
1) There is no syntax support for keyword-only parameters in 2.7.
2) This can break a correct code which passes flags as positional arguments.
----------
nosy: +serhiy.storchaka
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32961>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com