Differences creating tuples and collections.namedtuples
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Feb 19 03:57:25 EST 2013
Pardon me for the double-post, if any, my news client appears to have
eaten my first reply.
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