Lisp mentality vs. Python mentality

Carl Banks pavlovevidence at gmail.com
Sat Apr 25 16:31:37 EDT 2009


On Apr 25, 1:44 am, "Ciprian Dorin, Craciun"
<ciprian.crac... at gmail.com> wrote:
> On Sat, Apr 25, 2009 at 11:30 AM, "Martin v. Löwis" <mar... at v.loewis.de> wrote:
>
> >>>>     Ok... Then what's pythonic? Please give a pythonic implementation...
> >>> Use the builtin a==b, similar to (equal a b)
>
> >>     But how about extensibility?
> > [...]
>
> > I see that you allow for a different comparison function. I do wonder
> > what the use case for this is - in what application do you have to
> > compare two lists for equality, and the item's __eq__ is inappropriate?
> > What would break if you fix the item's __eq__, instead of writing
> > your own comparison algorithm?
>
> > [...]
>
>     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?

The practical way to deal with this issue is to write your own
function when you encounter a situation where == doesn't suffice.


Carl Banks



More information about the Python-list mailing list