On 20 ago, 12:48, mkPyVS <[EMAIL PROTECTED]> wrote:
> On Aug 20, 9:35 am, "Shawn Milochik" <[EMAIL PROTECTED]> wrote:
>
> As a side note unless you are searching large buffers it is possibly
> more costly to compile into a re object then do a match with it as
> opposed to let the match object perfo
On 8/20/07, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On Aug 20, 10:35 am, "Shawn Milochik" <[EMAIL PROTECTED]> wrote:
> > #!/usr/bin/env python
>
> > if __name__ == "__main__":
> >
> > print "The return for 'fred' : %s" % returnCode('fred')
> > print "The return for 'silk' : %s" % returnC
On Aug 20, 10:35 am, "Shawn Milochik" <[EMAIL PROTECTED]> wrote:
> #!/usr/bin/env python
> if __name__ == "__main__":
>
> print "The return for 'fred' : %s" % returnCode('fred')
> print "The return for 'silk' : %s" % returnCode('silk')
> print "The return for 'silky' : %s" % returnCode
On Aug 20, 9:35 am, "Shawn Milochik" <[EMAIL PROTECTED]> wrote:
> #!/usr/bin/env python
>
> import re
>
> patterns = { 'sho.' : 6, '.ilk' : 8, '.an.' : 78 }
>
> def returnCode(aWord):
> for k in patterns:
> p = "^%s$" % k
> regex = re.compile(p)
> if re.match(regex, aWor
#!/usr/bin/env python
import re
patterns = { 'sho.' : 6, '.ilk' : 8, '.an.' : 78 }
def returnCode(aWord):
for k in patterns:
p = "^%s$" % k
regex = re.compile(p)
if re.match(regex, aWord):
return patterns[k]
if __name__ == "__main__":
print "The retu
Hi
I have a dictionary with a list of patterns:
Code: ( text )
1. >>> words = {'sho.':6, '.ilk':8,'.an.':78 }
Where the "." character means any pattern - this can easily be changed to
the "*" symbol if need be.
When the user submits a word, I want to be able to look for a corresponding
pat