I have a weird NameError in Python 3.3.1 (win7).
Code:
import re # ... # Parse exclude patterns. excluded_regexps = set(re.compile(regexp) for regexp in options.exclude_pattern) # This is line 561: excluded_regexps |= set(re.compile(regexp, re.I) for regexp in options.exclude_pattern_ci)
Error:
Traceback (most recent call last): File "py3createtorrent.py", line 794, in <module> sys.exit(main(sys.argv)) File "py3createtorrent.py", line 561, in main excluded_regexps |= set(re.compile(regexp, re.I) for regexp in options.exclude_pattern_ci) File "py3createtorrent.py", line 561, in <genexpr> excluded_regexps |= set(re.compile(regexp, re.I) for regexp in options.exclude_pattern_ci) NameError: free variable 're' referenced before assignment in enclosing scope
Note that line 561, where the error occurs, is the second line in the code above. In other words: re not a free variable. This is just a regular expression module, and in the first line it can be perfectly edited.
It seems to me that the link to re.I is causing the problem, but I do not see how.
source share