Marc-Andre Lemburg <m...@egenix.com> added the comment: Brett Cannon wrote: > > Brett Cannon <br...@python.org> added the comment: > > But this is meant to be an optional warning; users will never see it. Me as a > developer, I would like to know when I leave a file open as that is a waste > of resources, plus with no guarantee of everything being flushed to disk.
That's what I'm referring to: most Python applications are written with the fact in mind, that garbage collection will close the files or socket. That's a perfectly fine way of writing Python applications, so why should the programmer get warned about this regular approach to Python programming ? > Besides, the context manager for files makes the chance of leaving a file > open a much more blaring mistake. See above: context aren't required for working with files. And again: it's *not* a mistake to not explicitly close a file. The same applies for sockets. Think of the simple idiom: data = open(filename).read() This would always create a warning under the proposal. Same for: for line in open(filename): print line Also note that files and sockets can be kept as references in data structures (other than local variables or on the stack) and there you usually have the same approach: you expect Python to close the files when garbage collecting the data structures and that's perfectly ok. If you want to monitor resource usage in your application it would be a lot more useful to provide access to the number of currently open FDs, than scattering warnings around the application which mostly trigger false positives. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10093> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com