Lisp mentality vs. Python mentality

Paul Rubin http
Sat Apr 25 05:00:05 EDT 2009


"Ciprian Dorin, Craciun" <ciprian.craciun at gmail.com> writes:
>     A practical example: I have lists that contain strings, but I want
> to compare them in an case-insensitive way... Should I update the
> __eq__ method (for str class) and break almost everything? Can I write
> now a == b? Nop... I need the loop you've just mentioned in all the
> places where the comparison changes just in the operator, not in the
> algorithm... (I would say this is bad coding practice...)

In Lisp I think you'd use (equal (mapcar upcase a) (mapcar upcase b))
or something like that.  In Python, a.upper() == b.upper().

Really, Python uses its object system more heavily than old-school
Lisp did, but in other regards (despite the howls of partisans on both
sides) they are really not that different from each other.



More information about the Python-list mailing list