to close or not to close?

Rainer Deyke root at rainerdeyke.com
Mon Jul 31 23:00:18 EDT 2000


"François Pinard" <pinard at iro.umontreal.ca> wrote in message
news:oq7la1u9k4.fsf at titan.progiciels-bpi.ca...
> I came to consider it is a better form to _not_ close explicitely.  Cases
> where explicit close is really useful are rather unusual, in my
experience.
> In which cases, an explicit `close' gets more meaningful, and less noisy.
> And even then, I much prefer `file = None' than `close(file)', because the
> former really represents my intent: I promise I will not use `file'
anymore.
> I like to think that closing a file is a system concern, not a user
concern.

Why not 'del file'?  This should catch attempts to use 'file' earlier, and
should be more memory efficient.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware action/role-playing games      -      http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list