Is a with on open always necessary?

Roy Smith roy at
Fri Jan 20 19:22:19 EST 2012

In article <mailman.4883.1327074990.27778.python-list at>,
 Arnaud Delobelle <arnodel at> wrote:

> > So maybe doing a
> >
> > with open(filename) as f:
> >     contents = f.readlines()
> That's what I do, unless I'm in an interactive session.

>From the resource management point of view, there's no doubt that's the 
right thing to be doing.  That being said, I don't bother most of the 
time and I can't think of a time when I've been bitten by it.

More information about the Python-list mailing list