[Python-ideas] Boolean value of file object?

Raymond Hettinger raymond.hettinger at gmail.com
Sun Jan 8 03:08:30 CET 2012


On Jan 7, 2012, at 5:07 PM, Mike Meyer wrote:

> Is there any reason a file object's boolean value shouldn't be false
> once it's been closed? 

Because that would make it harder to learn what things in Python can be False and what that implies.

Currently, None is always false, numbers are false when they are zero, and containers are false when they are empty.

Files objects don't fit into that model.  Some would question whether a file could be considered a container.  Even if a file was considered a container, there is still an important distinction between files that are closed versus files that are empty (i.e. they have a length of zero).

Lastly, the file API is adopted by many objects, so we would need to change them all.



Raymond

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120107/085d162f/attachment.html>


More information about the Python-ideas mailing list