regular expression dictionary search

Shawn Milochik Shawn at Milochik.com
Mon Aug 20 12:04:37 EDT 2007


On 8/20/07, Paul McGuire <ptmcg at austin.rr.com> wrote:
> 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
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


You're right. Thanks for the correction. My wrists are shot as it is,
and it's easy enough in vim to copy & paste. You know how it is -- I
made one test line, then copied it to a second, then copied it to a
third... Guilty of not planning ahead. ;o)



More information about the Python-list mailing list