[Python-checkins] cpython: Replace **locals() with explicit field names.
raymond.hettinger
python-checkins at python.org
Tue Mar 22 22:59:47 CET 2011
http://hg.python.org/cpython/rev/296a68fc2cc1
changeset: 68839:296a68fc2cc1
user: Raymond Hettinger <python at rcn.com>
date: Tue Mar 22 14:21:38 2011 -0700
summary:
Replace **locals() with explicit field names.
files:
Lib/collections/__init__.py
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -288,9 +288,6 @@
seen_names.add(name)
# Create and fill-in the class template
- numfields = len(field_names)
- argtxt = repr(field_names).replace("'", "")[1:-1] # tuple repr without parens or quotes
- reprtxt = ', '.join('{}=%r'.format(name) for name in field_names)
template = '''class {typename}(tuple):
'{typename}({argtxt})'
@@ -329,7 +326,14 @@
'Return self as a plain tuple. Used by copy and pickle.'
return tuple(self)
-'''.format(**locals())
+'''
+ template = template.format(
+ typename = typename,
+ field_names = field_names,
+ argtxt = repr(field_names).replace("'", "")[1:-1],
+ numfields = len(field_names),
+ reprtxt = ', '.join('{}=%r'.format(name) for name in field_names),
+ )
for i, name in enumerate(field_names):
template += " %s = _property(_itemgetter(%d), doc='Alias for field number %d')\n" % (name, i, i)
if verbose:
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list