This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients eric.smith, poornaprudhvi, rhettinger, serhiy.storchaka, terry.reedy
Date 2018-02-27.10:39:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1519727967.02.0.467229070634.issue32961@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-02-27 10:39:27serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, terry.reedy, eric.smith, poornaprudhvi
2018-02-27 10:39:27serhiy.storchakasetmessageid: <1519727967.02.0.467229070634.issue32961@psf.upfronthosting.co.za>
2018-02-27 10:39:27serhiy.storchakalinkissue32961 messages
2018-02-27 10:39:26serhiy.storchakacreate