Overloading operators on the rigth.

denis wendum wendum.denis at pasdepourriels.edf.fr
Thu Oct 14 01:59:39 EDT 2004



Alex Martelli a écrit :

> denis wendum <wendum.denis at pasdepourriels.edf.fr> wrote:
>
>
>
> Here's how to find out:
>
> >>> class foo:
> ...   def __getattr__(self, name):
> ...     print 'looking for %r' % name
> ...     raise AttributeError, name
> ...
> >>> f=foo()
> >>> 12 < f
> looking for '__gt__'
> looking for '__coerce__'
> looking for '__cmp__'
> True
> >>>
>
> See what's happening here?
>
> Alex

Many thanks for your answer: you didn't just gave me the fish I asked but also

showed me how to use a net for catching other fish.

It seems I triggered a fierce debate with my question, but as far as I'm
concerned your example worked perfectly.




More information about the Python-list mailing list