file.close()
Erik Max Francis
max at alcyone.com
Thu Jul 24 01:19:07 EDT 2003
Ben Finney wrote:
> This doesn't match Bryan's nested structure above, which you blessed
> as
> not "overkill" (in his words). It was this that I considered a
> poorly-scaling structure, or "overkill" since only one 'try' block is
> required. Do you disagree?
It uses try/finally to secure the closing of many files in a timely
manner. In that sense, it certainly fits the pattern. It doesn't have
the same nested pattern, but try/finally isn't at issue here. If you
had code which opened 50 files and looked like:
fileOne = file(...)
fileTwo = file(...)
fileThree = file(...)
...
fileFortyNine = file(...)
fileFifty = file(...)
I would say you are doing something wrong. A more systematic handling
of many, many files is indicated whether or not you're using the
try/finally idiom to ensure files get closed in a timely manner.
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ Together we can take this one day at a time
\__/ Sweetbox
More information about the Python-list
mailing list