On 11/13/2014 10:32 AM, Ethan Furman wrote:
> On 11/12/2014 01:51 PM, Ian Kelly wrote:
>> On Wed, Nov 12, 2014 at 2:33 PM, Chris Kaynor wrote:
>>>
>>> A decorator is an interesting idea, and should be easy to implement (only
>>> lightly tested):
>>>
>>> def main(func):
>>>      if func.__module__ == "__main__":
>>>              func()
>>>      return func # The return could be omitted to block the function from
>>> being manually called after import.
>>
>> This calls it at the wrong time, though.  [...]
> 
> One decorator that won't call too early is atexit.register().

Well, I've tried this out, and it's only okay.  As soon as interesting things 
start happening, spurious errors about
thread IDs start printing, which really messes up the user experience [1].


[1] something like Exception KeyError: KeyError(139924387112272,) in <module 
'threading' from
'/usr/lib/python2.7/threading.pyc'> ignored

--
~Ethan~

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to