diff options
author | Raymond Hettinger <python@rcn.com> | 2007-10-08 10:11:51 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-10-08 10:11:51 (GMT) |
commit | 0e1d6061163d5be4427ca7ec4edd6bd08b8dc9b8 (patch) | |
tree | 0dcfad68826a8f4b50e9ded19aaeca06e83b9a0e | |
parent | b6893f2bf8f65fcfc1c9acae4093210b7e560fc8 (diff) | |
download | cpython-0e1d6061163d5be4427ca7ec4edd6bd08b8dc9b8.zip cpython-0e1d6061163d5be4427ca7ec4edd6bd08b8dc9b8.tar.gz cpython-0e1d6061163d5be4427ca7ec4edd6bd08b8dc9b8.tar.bz2 |
Better variable names
-rw-r--r-- | Lib/collections.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/collections.py b/Lib/collections.py index c5eb79c..6a28553 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -30,7 +30,7 @@ def NamedTuple(typename, field_names, verbose=False): # Parse and validate the field names if isinstance(field_names, basestring): - field_names = s.replace(',', ' ').split() # names separated by spaces and/or commas + field_names = field_names.replace(',', ' ').split() # names separated by whitespace and/or commas field_names = tuple(field_names) if not ''.join((typename,) + field_names).replace('_', '').isalnum(): raise ValueError('Type names and field names can only contain alphanumeric characters and underscores') @@ -60,12 +60,12 @@ def NamedTuple(typename, field_names, verbose=False): print template # Execute the template string in a temporary namespace - m = dict(itemgetter=_itemgetter) + namespace = dict(itemgetter=_itemgetter) try: - exec template in m + exec template in namespace except SyntaxError, e: raise SyntaxError(e.message + ':\n' + template) - result = m[typename] + result = namespace[typename] # For pickling to work, the __module__ variable needs to be set to the frame # where the named tuple is created. Bypass this step in enviroments where |