On Fri, Oct 9, 2009 at 04:45, Steve Borho <st...@borho.org> wrote: > > > On Thu, Oct 8, 2009 at 2:36 PM, Adrian Buehlmann <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+.
For instance, we use 'lambda' and call a function returns result evaluates as True in it: def hoge(): # do something return True bool(lambda: hoge()) In lambda function, it will return the result of expression without explicit 'return' statement. Some time ago, I've replaced it to normal function, but it has possibility to go endless calling. -- Yuki KODAMA ------------------------------------------------------------------------------ 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