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 rhettinger
Recipients rhettinger
Date 2015-08-17.05:33:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Currently, help() lists out data descriptors in alphabetical order.  This is fine in the general case, however if the fields are parts of a named tuple, it is more sensible to list them in the order found in the tuple.

The presence of a named tuple can be detected by the presence of a _fields attribute that is a list of strings.  That strings can be used as a primary sort key before an alphabetical sort of anything not listed in _fields.

>>> Person = namedtuple('Person', ['nickname', 'firstname', 'age'])
>>> help(Person)
Help on class Person in module __main__:

class Person(builtins.tuple)
 |  Person(nickname, firstname, age)
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |  __new__(_cls, nickname, firstname, age)
 |      Create new instance of Person(nickname, firstname, age)
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  __dict__
 |      A new OrderedDict mapping field names to their values
 |  age
 |      Alias for field number 2
 |  firstname
 |      Alias for field number 1
 |  nickname
 |      Alias for field number 0
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |  _fields = ('nickname', 'firstname', 'age')

The data descriptors should list nickname, then firstname, then age to match the tuple order in _fields.
Date User Action Args
2015-08-17 05:33:10rhettingersetrecipients: + rhettinger
2015-08-17 05:33:10rhettingersetmessageid: <>
2015-08-17 05:33:10rhettingerlinkissue24879 messages
2015-08-17 05:33:07rhettingercreate