On Mar 21, 12:48 pm, Martin Manns <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Is there a way to create a function that is equal to 0?
> I try to redefine __cmp__ but I am pretty stuck.
>
> Something like:
>
> >>> def f(): return ""
> ...
> >>> # Some magic
> >>> f == 0
>
> True
>


You would have to bind f (the name)
to 0 (or False).  You can "cheat"
and use a decorator:

>>> def makezero(f): return 0

>>> @makezero
... def f(): return 1

>>> f == 0
True

--
Hope this helps,
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to