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

Stephen J. Turnbull turnbull.stephen.fw at u.tsukuba.ac.jp
Thu Jul 27 21:21:43 EDT 2017


MRAB writes:

 > But what about:
 > 
 >  >>> nt2 = ntuple(y=2, x=1)
 > 
 > ? Does that mean that nt[0] == 2? Presumably, yes.
 > 
 > Does nt == nt2?
 > 
 > If it's False, then you've lost some of the advantage of using names 
 > instead of positions.

Sure.  And if you use a dict, you've lost some of the advantage of
using names instead positions too.

I'm not sure a somewhat hacky use case (see my reply to Ethan
elsewhere in the thread) justifies a builtin, but I can easily see
using it myself if it did exist.

Steve


More information about the Python-ideas mailing list