[Python-ideas] Anonymous namedtuples
Paul Moore
p.f.moore at gmail.com
Tue Apr 19 06:25:07 EDT 2016
On 19 April 2016 at 11:06, Chris Angelico <rosuav at gmail.com> wrote:
> That said, though: I don't often feel the yearning for quick
> namedtuples. A function that today returns a namedtuple of 'x' and 'y'
> can't in the future grow a 'z' without breaking any callers that
> unpack "x, y = func()", so extensible return objects have to forego
> unpacking (eg using a dict or SimpleNamespace).
Possibly the docs for namedtuple should refer the user to
SimpleNamespace as an alternative if "being a tuple subclass" isn't an
important requirement. Or possibly SimpleNamespace should be in the
collections module (alongside namedtuple) rather than in the types
module?
The issue may simply be that SimpleNamespace isn't as discoverable as
it should be?
Paul
More information about the Python-ideas
mailing list