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 tim.peters
Recipients docs@python, tim.peters
Date 2019-09-10.22:05:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1568153124.61.0.864461609465.issue38096@roundup.psfhosted.org>
In-reply-to
Content
The Glossary has this entry:

"""
struct sequence
A tuple with named elements. Struct sequences expose an interface similar to named tuple in that elements can be accessed either by index or as an attribute. However, they do not have any of the named tuple methods like _make() or _asdict(). Examples of struct sequences include sys.float_info and the return value of os.stat().
"""

It's trying to document the internal CPython implementation `structseq` detail, a class of which can only be created from the C API (no Python interface is exposed).

But the glossary _also_ has an entry for "named tuple", and the docs just above are confusing that for the related but distinct `collections.namedtuple` facility, which does allow creating a named tuple class from Python, but is NOT the only kind of "named tuple".

This is a mess ;-)

I suggest:

- Throw away the "struct sequence" glossary entry, and remove all references to it from the docs.

- Use "named tuple" everywhere instead.

- Clarify the "named tuple" docs to make clear that it applies to any class that supports tuple methods and also named elements.

- Make clear that `collections.namedtuple` classes are "named tuples" classes, but not the only kind, and support a number of methods beyond what's required for "named tuples".

- Optionally, effectively expose `structseq` to Python code, so that users have one obvious way to create their own bare-bones named tuple types.

- I'd prefer to insist that for any named tuple class C,

  issubclass(C, tuple)
  
  is True.  That's true now of structseqs and collections.namedtuples, and is a sane way to make clear that they must support all tuple methods.
  
I'd mark this as "newcomer friendly", except it's likely to become a bikeshedding nightmare ;-)
History
Date User Action Args
2019-09-10 22:05:24tim.peterssetrecipients: + tim.peters, docs@python
2019-09-10 22:05:24tim.peterssetmessageid: <1568153124.61.0.864461609465.issue38096@roundup.psfhosted.org>
2019-09-10 22:05:24tim.peterslinkissue38096 messages
2019-09-10 22:05:24tim.peterscreate