terry added the comment:

My real application (not this example code that also 'breaks') is a battery 
monitor that starts at boot time and only exits when the battery is near death. 

So there is effectively a while(batlevelgood) loop that polls the battery level 
and doesn't exit until  near battery death.

I only encounters this while debugging and having to kill (ctrl-c) the script, 
having no chance to clean up properly.

Admittedly I'm not very experienced in Python but I am an experienced 
programmer.  I will look up context mgr protocol, but this was certainly odd 
behavior.  It isn't every day that the name of a  function not even called 
changes observed program behavior.

Terry

> On Nov 13, 2015, at 1:42 PM, R. David Murray <rep...@bugs.python.org> wrote:
> 
> 
> R. David Murray added the comment:
> 
> Best practice, by the way, is to be explicit about the scope of any resource 
> and clean it up before program end...this is often done by using the context 
> manager protocol.
> 
> ----------
> 
> _______________________________________
> Python tracker <rep...@bugs.python.org>
> <http://bugs.python.org/issue25619>
> _______________________________________

----------
title: Exception AttributeError: "'NoneType'....  thrown on exit -> Exception 
AttributeError: "'NoneType'.... thrown on exit

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25619>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to