[Tutor] Can you see my error?
Danny Yoo
dyoo@hkn.eecs.berkeley.edu
Fri, 3 Aug 2001 16:01:32 -0700 (PDT)
On Fri, 3 Aug 2001 DavidCraig@pia.ca.gov wrote:
> The message I get is:
>
> >>>
> Traceback (most recent call last):
> File "C:/Python21/Practice/therapist1.py", line 273, in ?
> gKeys = map(lambda x:regex.compile(x[0]),gPats)
> File "C:/Python21/Practice/therapist1.py", line 273, in <lambda>
> gKeys = map(lambda x:regex.compile(x[0]),gPats)
> error: Badly placed parenthesis
I don't see anything wrong with the parentheses in the map expression.
Perhaps it might have something to do with the string you're passing into
regex.compile: regular expressions, too, use parentheses when they compile
a pattern. Maybe that error message is coming from the regular expression
engine, and not Python.
As a debugging tool, can you do the following?
###
gKeys = []
for pattern in gPats:
print "I'm going to compile", pattern[0], "now."
gKeys.append(regex.compile(pattern[0]))
###
It's longer, but it might give us some idea of what's going on. Also, you
may want to use the "re" module instead of the "regex" library --- regex
is a bit deprecated.
Good luck!