Author yselivanov
Recipients rhettinger, yselivanov
Date 2015-08-18.03:29:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1439868581.44.0.29461308449.issue24879@psf.upfronthosting.co.za>
In-reply-to
Content
> Named tuples are not a type, they are a protocol.  Guido has agreed that checking for _fields is an acceptable and preferred way of finding out whether something is a namedtuple.

They are, but for protocols we usually use dunder names.  "_fields" is a common enough attribute name for all kinds of objects, not necessarily namedtuples.

Can we at least check if the class is a tuple subclass and then use its '_fields' for sorting?

> I can add a check to at least check the value of _fields is an iterable of strings.  If it still aliases with some random use of _fields, the only consequence is that the matching field names will appear in a different order.

+1 for checking if it's an iterable of strings.
History
Date User Action Args
2015-08-18 03:29:41yselivanovsetrecipients: + yselivanov, rhettinger
2015-08-18 03:29:41yselivanovsetmessageid: <1439868581.44.0.29461308449.issue24879@psf.upfronthosting.co.za>
2015-08-18 03:29:41yselivanovlinkissue24879 messages
2015-08-18 03:29:40yselivanovcreate