Differences creating tuples and collections.namedtuples

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue Feb 19 09:06:26 CET 2013


On Mon, 18 Feb 2013 23:48:46 -0800, raymond.hettinger wrote:

[...]
> If your starting point is an existing iterable such as s=['Guido',
> 'BDFL', 1], you have a couple of choices:   p=Person(*s) or
> p=Person._make(s).  The latter form was put it to help avoid unpacking
> and repacking the arguments.


It might not be obvious to the casual reader, but despite the leading 
underscore, _make is part of the public API for namedtuple:

http://docs.python.org/2/library/collections.html#collections.namedtuple



-- 
Steven



More information about the Python-list mailing list