On 20 Okt, 21:13, "Gabriel Genellina" <gagsl-...@yahoo.com.ar> wrote:
> En Tue, 20 Oct 2009 04:47:02 -0300, arve.knud...@gmail.com  
> <arve.knud...@gmail.com> escribió:
>
> > On 20 Okt, 09:40, "Gabriel Genellina" <gagsl-...@yahoo.com.ar> wrote:
> >> En Tue, 20 Oct 2009 03:23:49 -0300, arve.knud...@gmail.com  
> >> <arve.knud...@gmail.com> escribió:
> >> > I agree, but like I said, I've been told that this (implicit closing
> >> > of files) is the correct style by more merited Python developers, so
> >> > that made me think I was probably wrong ..
>
> >> Then tell those "more merited Python developers" that they're wrong,  
> >> and that the right way to ensure a file is closed when you're done with  
> >> it is to use a `with` statement (or a try/finally block in old Python  
> >> releases)
>
> > Easier said than done :) In any case, I now have this discussion as a
> > useful reference in the future. Thanks!
>
> If this thread is not enough, you can ask them to read the official Python  
> tutorial:
>
> "It is good practice to use the with keyword when dealing with file  
> objects. This has the advantage that the file is properly closed after its  
> suite finishes, even if an exception is raised on the way. It is also much  
> shorter than writing equivalent try-finally blocks."
>
> http://docs.python.org/tutorial/inputoutput.html#methods-of-file-objects

Perhaps the general attitude has changed now that the "with" keyword
makes it so easy anyway (unless one needs to support older Pythons of
course).

Arve
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to