mirror of
https://github.com/python/cpython.git
synced 2025-10-14 10:53:40 +00:00
Have namedtuple's field renamer assign names that
are consistent with the corresponding tuple index.
This commit is contained in:
parent
c26d43966d
commit
5614524293
2 changed files with 7 additions and 7 deletions
|
@ -174,7 +174,7 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
|
|||
if (not all(c.isalnum() or c=='_' for c in name) or _iskeyword(name)
|
||||
or not name or name[0].isdigit() or name.startswith('_')
|
||||
or name in seen):
|
||||
names[i] = '_%d' % (i+1)
|
||||
names[i] = '_%d' % i
|
||||
seen.add(name)
|
||||
field_names = tuple(names)
|
||||
for name in (typename,) + field_names:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue