Oops, forgot to test this after the merge.

This commit is contained in:
Guido van Rossum 2007-11-16 00:48:13 +00:00
parent 3d392eb327
commit 053b4f3a0e
1 changed files with 2 additions and 2 deletions

View File

@ -70,7 +70,7 @@ def namedtuple(typename, field_names, verbose=False):
return dict(zip(%(field_names)r, self)) return dict(zip(%(field_names)r, self))
def __replace__(self, **kwds): def __replace__(self, **kwds):
'Return a new %(typename)s object replacing specified fields with new values' 'Return a new %(typename)s object replacing specified fields with new values'
return %(typename)s(**dict(zip(%(field_names)r, self) + kwds.items())) \n''' % locals() return %(typename)s(**dict(list(zip(%(field_names)r, self)) + list(kwds.items()))) \n''' % locals()
for i, name in enumerate(field_names): for i, name in enumerate(field_names):
template += ' %s = property(itemgetter(%d))\n' % (name, i) template += ' %s = property(itemgetter(%d))\n' % (name, i)
if verbose: if verbose:
@ -105,7 +105,7 @@ if __name__ == '__main__':
# test and demonstrate ability to override methods # test and demonstrate ability to override methods
Point.__repr__ = lambda self: 'Point(%.3f, %.3f)' % self Point.__repr__ = lambda self: 'Point(%.3f, %.3f)' % self
print p print(p)
import doctest import doctest
TestResults = namedtuple('TestResults', 'failed attempted') TestResults = namedtuple('TestResults', 'failed attempted')