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 NeilGirdhar
Recipients NeilGirdhar, alexdelorenzo, eric.smith, levkivskyi
Date 2018-08-10.04:26:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Sorry if I'm intruding here, but I really dislike that we are doing isinstance versus list, tuple, and dict.  And I dislike even more type(x) in (list, tuple).  I think the ideal thing to do would have been to check versus abstract base classes like isinstance(x, Sequence) and isinstance(x, Mapping).  The advantage to this is flexibility with user-defined types.

The problem seems to be that the abstract base classes don't promise anything about the constructor.  It seems like some Sequence types accept an Iterable (e.g. tuple), but others like NamedTuple want positional arguments.  I think this promise should be encoded in some way.

Maybe a third solution is to have NamedTuple special-cased out:

isinstance(x, Sequence) and not isinstance(x, NamedTuple)

If there are other Sequence types that do this (are there?) then an abstract base class could be created.

This solution has the benefit of playing the most nicely with user-defined classes.
Date User Action Args
2018-08-10 04:27:00NeilGirdharsetrecipients: + NeilGirdhar, eric.smith, levkivskyi, alexdelorenzo
2018-08-10 04:27:00NeilGirdharsetmessageid: <>
2018-08-10 04:27:00NeilGirdharlinkissue34363 messages
2018-08-10 04:26:59NeilGirdharcreate