[New-bugs-announce] [issue2909] struct.Struct.unpack to return a namedtuple for easier attribute access
report at bugs.python.org
Sun May 18 22:13:20 CEST 2008
New submission from Aaron Gallagher <habnabit at gmail.com>:
With the advent of collections.namedtuple, I thought that having a
counterpart in the struct module would make having to deal with unpacked
data much easier. Per suggestion, this extends the behavior of
_struct.Struct rather than a separate NamedStruct class.
The regexp might not be immediately obvious as to what the format
required is. The format string is represented like this:
and so on. Formats given in parentheses without an attribute name are
allowed, so that byte order and pad bytes can be specified. For example:
"(!) x1(h) x2(h) (2x) y1(h) y2(h)"
Suggestions and criticism are welcome. I think it would simplify using
the struct module a lot to be able to have named attributes like this.
components: Library (Lib)
title: struct.Struct.unpack to return a namedtuple for easier attribute access
versions: Python 3.0
Added file: http://bugs.python.org/file10368/named-struct.patch
Tracker <report at bugs.python.org>
More information about the New-bugs-announce