Paul Rubin <http://phr...@nospam.invalid> writes:

> "Ciprian Dorin, Craciun" <ciprian.crac...@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 simply (equalp a b), since equalp comparisons happen to compare
strings case-insensitively.  But that's Common Lisp... overflowing
kitchen sink.

> or something like that.  In Python, a.upper() == b.upper().

I guess you meant map(a, str.upper) == map(b, str.upper)?  a and b are
lists of strings.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to