imported method from module evaluates to None in some cases

Peter Otten __peter__ at web.de
Sun Nov 23 06:23:12 EST 2008


Paul McGuire wrote:

> On Nov 23, 4:21 am, Hrvoje Niksic <hnik... at xemacs.org> wrote:
>>
>> I don't know why the interpreter would shut down abruptly, but I
>> suppose you could inspect the traceback to see what exactly caused the
>> exception?- Hide quoted text -
>>
> While you puzzle out the root cause, could something like this help
> alleviate your race condition at interpreter shutdown?
> 
> -- Paul
> 
> 
> def safe_call(fn, alt):
>     if fn is not None:
>         return fn
>     return alt
> 
> def WakeupAlt():
>     print "Wakeup has been set to None"
> 
> def Wakeup():
>     print "This is your wakeup call..."
> 
> safe_call(Wakeup,WakeupAlt)()
> Wakeup = None
> safe_call(Wakeup,WakeupAlt)()
> 
> prints:
> This is your wakeup call...
> Wakeup has been set to None

Hm, what makes you confident that neither WakupAlt() nor safe_call() may be
set to None, too?

Peter



More information about the Python-list mailing list