On 08.10.2009 21:45, Steve Borho wrote:
> 
> 
> On Thu, Oct 8, 2009 at 2:36 PM, Adrian Buehlmann <adr...@cadifra.com
> <mailto:adr...@cadifra.com>> wrote:
> 
>     On 08.10.2009 20:57, Steve Borho wrote:
>     > FYI
>     >
>     > I realized today that we need to explicitly 'return False' from all of
>     > our idle_add() callback routines.
>     > If the return result evaluates as True, the callback will be called
>     > endlessly.
>     >
> 
>     Maybe I'm totally wrong here, but...
> 
>     A function that does not explicitly return a value
>     returns None, which counts as False.
> 
>     Correct?
> 
>     So we have a problem only with functions that
>     return a value.
> 
> 
> Good question.  I assumed Python worked like a shell and just returned
> the result of the last operation.
> 
>>>> def foo():
> ...    a=True
> ...
>>>> foo()
>>>> bool(foo())
> False
> 
> 
> Yep, you're right.  We only need to be worried about functions that
> return a value.  Though it wouldn't be a bad idea to return False in
> these functions as a way to document the way idle_add() routines are
> used by GTK+.

How about defining a

class call_once(object):
    def __init__(self, f):
        self.f = f
    def __call__(self):
        self.f()
        return False

in a utility module and then use it like this (example):

    gobject.idle_add(call_once(self.realize_settings))

?


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Tortoisehg-develop mailing list
Tortoisehg-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to