440,621 Members | 1,101 Online
Need help? Post your question and get tips & solutions from a community of 440,621 IT Pros & Developers. It's quick & easy.

# How can I make a function equal to 0?

 P: n/a 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 magicf == 0 True Thanks in advance Martin Mar 21 '08 #1
8 Replies

 P: n/a Martin Manns

 P: n/a On 21 Mar 2008 12:52:12 -0700 Paul Rubin >def f(): return 0 .... >>f==0 False >>f()==0 True >>> I do not want the function to return 0 but to equal 0. Martin Mar 21 '08 #3

 P: n/a On Mar 21, 12:48 pm, Martin Manns def f(): return "" ... ># Some magicf == 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 Mar 21 '08 #4

 P: n/a Martin Manns

 P: n/a On Mar 22, 8:51 am, Gabriel Genellina

 P: n/a On Fri, 21 Mar 2008 14:51:49 -0700 (PDT) Gabriel Genellina

 P: n/a On 21 mar, 19:25, John Machin

 P: n/a On Mar 22, 3:32 pm, Gabriel Genellina

### This discussion thread is closed

Replies have been disabled for this discussion.