Differences creating tuples and collections.namedtuples

Roy Smith roy at panix.com
Mon Feb 18 20:11:38 EST 2013


Terry Reedy <tjreedy at udel.edu> wrote:

> Initializaing a namedtuple from an iterable is unusual, and 
> hence gets the longer syntax. I

I quick look through our codebase agrees with that.  I found 27 
namedtuple classes.  21 were initialized with MyTuple(x, y, z) syntax.  
Three used MyTuple(*data).

Most interesting were the three that used MyTuple(**data).  In all three 
cases, data was a dictionary returned by re.match.groupdict().  The 
definition of the namedtuple was even built by introspecting the regex 
to find all the named groups!



More information about the Python-list mailing list