regular expression dictionary search
Paul McGuire
ptmcg at austin.rr.com
Mon Aug 20 11:54:55 EDT 2007
On Aug 20, 10:35 am, "Shawn Milochik" <Sh... at Milochik.com> wrote:
> #!/usr/bin/env python
<snip>
> 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('silky')
> print "The return for 'hand' : %s" % returnCode('hand')
> print "The return for 'strand' : %s" % returnCode('strand')
> print "The return for 'bank' : %s" % returnCode('bank')
>
Shawn -
All that copy/pasting has got to have carpal tunnel written all over
it - DRY!
tests = "fred silk silky hand strand bank".split()
for test in tests:
print "The return for '%s' : %s" % (test, returnCode(test))
-- Paul
More information about the Python-list
mailing list