[issue20230] structseq types should expose _fields

2014-04-29 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
resolution:  - duplicate
stage:  - resolved
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20230
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20230] structseq types should expose _fields

2014-04-29 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
superseder:  - Enhance Object/structseq.c to match namedtuple and tuple
api

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20230
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20230] structseq types should expose _fields

2014-04-27 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
nosy: +skrah

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20230
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20230] structseq types should expose _fields

2014-01-12 Thread Andrew Barnert

New submission from Andrew Barnert:

A PyStructSequence type doesn't expose its field names in any way to Python 
code (except indirectly, via the repr, which you could parse if you really 
wanted to…).

The docs claim that Struct sequence objects are the C equivalent of 
namedtuple() objects, so it seems like the obvious way to expose them is the 
exact same way namedtuple types do—as a class attribute named _fields.

Also, in #7796, and in a recent thread on python-ideas, multiple people 
suggested that named tuple is a protocol, not a type, and duck typing on 
_fields is the obvious way to detect types matching that protocol.

Only the sequence fields need to be exposed—fields that don't match up to 
sequence indices aren't named tuple fields, they're just extra instance 
attributes (that don't even show up in the repr).

Patch included. For the tests, I tested the fields in struct_time and 
stat_result in effectively the same way test_repr tests their repr, so it 
should pass on all the same platforms/builds.

--
files: structseq.diff
keywords: patch
messages: 207991
nosy: abarnert
priority: normal
severity: normal
status: open
title: structseq types should expose _fields
type: enhancement
Added file: http://bugs.python.org/file33436/structseq.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20230
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20230] structseq types should expose _fields

2014-01-12 Thread Meador Inge

Changes by Meador Inge mead...@gmail.com:


--
nosy: +meador.inge

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20230
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20230] structseq types should expose _fields

2014-01-12 Thread Andrew Barnert

Andrew Barnert added the comment:

After more searching (I should have searched on structseq instead of 
PyStructSequence…), this might be a dup of #1820. If so, apologies.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20230
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20230] structseq types should expose _fields

2014-01-12 Thread Ethan Furman

Changes by Ethan Furman et...@stoneleaf.us:


--
nosy: +ethan.furman

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20230
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20230] structseq types should expose _fields

2014-01-12 Thread Yury Selivanov

Changes by Yury Selivanov yseliva...@gmail.com:


--
nosy: +yselivanov

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20230
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20230] structseq types should expose _fields

2014-01-12 Thread Yury Selivanov

Changes by Yury Selivanov yseliva...@gmail.com:


--
components: +Interpreter Core, Library (Lib)
versions: +Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20230
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com