object.enable() anti-pattern
Roy Smith
roy at panix.com
Thu May 9 20:50:16 EDT 2013
In article <mailman.1514.1368145123.3114.python-list at python.org>,
Michael Speer <knomenet at gmail.com> wrote:
> By his reasoning it simply shouldn't exist. Instead you would access the
> information only like this:
>
> with open("myfile.dat") as f:
> data = f.read()
The problem with things like file objects is they model external
real-world entities, which have externally-imposed real-world behaviors.
f.close() can fail, most commonly because some buffered output couldn't
be written when being flushed as part of the close(). Sometimes it's
important to find out about that.
More information about the Python-list
mailing list