Lisp mentality vs. Python mentality

Brett Hoerner bretthoerner at gmail.com
Sat Apr 25 22:36:49 CEST 2009


On Apr 25, 8:11 am, "Ciprian Dorin, Craciun"
<ciprian.crac... at gmail.com> wrote:
>     Well in fact I would have written it like:
>
> def validate_commandline(rexes, line) :
>     if not compare (rexes, line, re.match) :
>         if len (rexes) != len (line) :
>             raise ValueError ("mismatch len")
>         mismatch = find_index (rexes, line, re.match, negate = True)
>         raise ValueError ("mismatch at %d" % (mismatch))
>
>     Assuming, that I would have the function find_index.
>
>     Ciprian.

I think you've hit on the definition of "unpythonic".  (No, I don't
have a dictionary definition for you, sorry).

Using a function called "compare" to run a list of regexes against
another list of regexes to get a boolean?  And then another find_index
function doing the same where you pass in negate?  What is even going
on here?

I, for one, would take Martin's any day of the week.  It reads like
good pseudocode as much "proper" Python does.

Brett



More information about the Python-list mailing list