[Tutor] re.compile and objects - what am doing wrong?

Alan Gauld alan.gauld at freenet.co.uk
Tue Dec 28 00:48:14 CET 2004

Hi Mark,

> for key in polishKeys:
> searchPat=re.compile("%s") % key # Doesn't work 
> for rKey in roughKeys:
>     if searchPat.match(rKey): print key+"----"+rKey

It should work, but it may be a bad string - ie not a 
valid regular expression? What errors do you get? 
What does the key string look like? (try inserting 
a print command before the compile)

We need a wee bit more detail on what's going wrong.

Alan G.
"Show me your flowcharts and conceal your tables, 
and I'll continue to be mystified. Show me your tables, 
and I won't usually need your flowcharts" 
- Fred Brooks, The Mythical Man Month

More information about the Tutor mailing list