[Python-ideas] namedtuple literals [Was: RE a new namedtuple]

Paul Moore p.f.moore at gmail.com
Sun Jul 30 14:31:02 EDT 2017

On 30 July 2017 at 16:24, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Rather than being about any changes on that front, these threads are
> mostly about making it possible to write that first line as:
>     MyNT = type(implicitly_typed_named_tuple_factory(foo=None, bar=None))

Is that really true, though? There's a lot of discussion about whether
ntuple(x=1, y=2) and ntuple(y=2, x=1) are equal (which implies they
are the same type). If there's any way they can be the same type, then
your definition of MyNT above is inherently ambiguous, depending on
whether we've previously referred to
implicitly_typed_named_tuple_factory(bar=None, foo=None).

For me, the showstopper with regard to this whole discussion about
ntuple(x=1, y=2) is this key point - every proposed behaviour has
turned out to be surprising to someone (and not just in a "hmm, that's
odd" sense, but rather in the sense that it'd almost certainly result
in bugs as a result of misunderstood behaviour).


More information about the Python-ideas mailing list