diff options
author | Raymond Hettinger <python@rcn.com> | 2007-12-18 23:51:15 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-12-18 23:51:15 (GMT) |
commit | 85dfcf35304935521085253ce5573feab21177d5 (patch) | |
tree | 4e50ffb80dba2e3b6332979fa44eb775aa14418e /Lib/collections.py | |
parent | 0a8143f6462b491d3f12bfb899efd6e044e350be (diff) | |
download | cpython-85dfcf35304935521085253ce5573feab21177d5.zip cpython-85dfcf35304935521085253ce5573feab21177d5.tar.gz cpython-85dfcf35304935521085253ce5573feab21177d5.tar.bz2 |
Users demand iterable input for named tuples. The author capitulates.
Diffstat (limited to 'Lib/collections.py')
-rw-r--r-- | Lib/collections.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/collections.py b/Lib/collections.py index 3d98f7c..c6d0d0f 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -62,6 +62,7 @@ def namedtuple(typename, field_names, verbose=False): __slots__ = () \n def __new__(cls, %(argtxt)s): return tuple.__new__(cls, (%(argtxt)s)) \n + _cast = classmethod(tuple.__new__) \n def __repr__(self): return '%(typename)s(%(reprtxt)s)' %% self \n def _asdict(t): @@ -69,7 +70,7 @@ def namedtuple(typename, field_names, verbose=False): return {%(dicttxt)s} \n def _replace(self, **kwds): 'Return a new %(typename)s object replacing specified fields with new values' - return %(typename)s(*map(kwds.get, %(field_names)r, self)) \n + return %(typename)s._cast(map(kwds.get, %(field_names)r, self)) \n @property def _fields(self): return %(field_names)r \n\n''' % locals() |