[Python-ideas] Boolean value of file object?
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas