Why no warnings when re-assigning builtin names?
tjreedy at udel.edu
Wed Aug 17 04:15:03 CEST 2011
On 8/16/2011 8:18 PM, Philip Semanchuk wrote:
> Hi Terry,
> To generalize from your example, are you saying that there's a mild admonition
> against shadowing builtins with unrelated variable names in standard
I would expect that there might be. I would have to check PEP8.
> Here's an example from Python 3.2.1's argparse.py, lines 466-473.
> "open" is shadowed on the second line.
> # clean up separators for mutually exclusive groups
> open = r'[\[(]'
> close = r'[\])]'
> text = _re.sub(r'(%s) ' % open, r'\1', text)
> text = _re.sub(r' (%s)' % close, r'\1', text)
> text = _re.sub(r'%s *%s' % (open, close), r'', text)
> text = _re.sub(r'\(([^|]*)\)', r'\1', text)
> text = text.strip()
Terry Jan Reedy
More information about the Python-list