Re: File not closed on exception

2009-10-20 Thread arve.knud...@gmail.com
On 20 Okt, 21:13, "Gabriel Genellina" wrote: > En Tue, 20 Oct 2009 04:47:02 -0300, arve.knud...@gmail.com   > escribió: > > > On 20 Okt, 09:40, "Gabriel Genellina" wrote: > >> En Tue, 20 Oct 2009 03:23:49 -0300, arve.knud...@gmail.com   > >> escribió: > >> > I agree, but like I said, I've been

Re: File not closed on exception

2009-10-20 Thread Gabriel Genellina
En Tue, 20 Oct 2009 04:47:02 -0300, arve.knud...@gmail.com escribió: On 20 Okt, 09:40, "Gabriel Genellina" wrote: En Tue, 20 Oct 2009 03:23:49 -0300, 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 b

Re: File not closed on exception

2009-10-20 Thread arve.knud...@gmail.com
On 20 Okt, 16:00, Bruno Desthuilliers wrote: > What's your problem with the with ??? No problem whatsoever, but I believe I wrote this utility function before the keyword was available, and it might be good to support older Python versions. > But anyway : explicitely releasing resources such as

Re: File not closed on exception

2009-10-20 Thread Bruno Desthuilliers
arve.knud...@gmail.com a écrit : On Oct 19, 4:14 pm, Grant Edwards wrote: On 2009-10-19, arve.knud...@gmail.com wrote: I thought that file objects were supposed to be garbage-collected and automatically closed once they go out of scope, At some point after they go out of scope, they will be

Re: File not closed on exception

2009-10-20 Thread Ethan Furman
arve.knud...@gmail.com wrote: On Oct 19, 3:48 pm, Ethan Furman wrote: arve.knud...@gmail.com wrote: Hi I thought that file objects were supposed to be garbage-collected and automatically closed once they go out of scope, at least that's what I've been told by more merited Python programme

Re: File not closed on exception

2009-10-20 Thread Mel
arve.knud...@gmail.com wrote: > 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 .. It would be nice. The trouble is that CPython is not the only Python. Jython,

Re: File not closed on exception

2009-10-20 Thread Ulrich Eckhardt
arve.knud...@gmail.com wrote: > On Oct 19, 3:48 pm, Ethan Furman wrote: >> arve.knud...@gmail.com wrote: [...] >>> def create(): >>> f = file("tmp", "w") >>> raise Exception >>> >>> try: >>> create() >>> finally: >>> os.remove("tmp") >>> [...] >> When an exception is raised, the e

Re: File not closed on exception

2009-10-20 Thread arve.knud...@gmail.com
On 20 Okt, 09:40, "Gabriel Genellina" wrote: > En Tue, 20 Oct 2009 03:23:49 -0300, arve.knud...@gmail.com   > escribió: > > > > > > > On Oct 19, 5:56 pm, "Gabriel Genellina" > > wrote: > >> En Mon, 19 Oct 2009 09:45:49 -0200, arve.knud...@gmail.com   > >> escribió: > > >> > I thought that file

Re: File not closed on exception

2009-10-20 Thread Gabriel Genellina
En Tue, 20 Oct 2009 03:23:49 -0300, arve.knud...@gmail.com escribió: On Oct 19, 5:56 pm, "Gabriel Genellina" wrote: En Mon, 19 Oct 2009 09:45:49 -0200, arve.knud...@gmail.com   escribió: > I thought that file objects were supposed to be garbage-collected and > automatically closed once they

Re: File not closed on exception

2009-10-19 Thread arve.knud...@gmail.com
On Oct 19, 5:56 pm, "Gabriel Genellina" wrote: > En Mon, 19 Oct 2009 09:45:49 -0200, arve.knud...@gmail.com   > escribió: > > > I thought that file objects were supposed to be garbage-collected and > > automatically closed once they go out of scope, at least that's what > > I've been told by more

Re: File not closed on exception

2009-10-19 Thread arve.knud...@gmail.com
On Oct 19, 4:14 pm, Grant Edwards wrote: > On 2009-10-19, arve.knud...@gmail.com wrote: > > > I thought that file objects were supposed to be > > garbage-collected and automatically closed once they go out of > > scope, > > At some point after they go out of scope, they will be. > Eventually.  Ex

Re: File not closed on exception

2009-10-19 Thread arve.knud...@gmail.com
On Oct 19, 3:48 pm, Ethan Furman wrote: > arve.knud...@gmail.com wrote: > > Hi > > > I thought that file objects were supposed to be garbage-collected and > > automatically closed once they go out of scope, at least that's what > > I've been told by more merited Python programmers. I'm also quite

Re: File not closed on exception

2009-10-19 Thread Gabriel Genellina
En Mon, 19 Oct 2009 09:45:49 -0200, arve.knud...@gmail.com escribió: I thought that file objects were supposed to be garbage-collected and automatically closed once they go out of scope, at least that's what I've been told by more merited Python programmers. An object (any object) is destro

Re: File not closed on exception

2009-10-19 Thread Grant Edwards
On 2009-10-19, arve.knud...@gmail.com wrote: > I thought that file objects were supposed to be > garbage-collected and automatically closed once they go out of > scope, At some point after they go out of scope, they will be. Eventually. Exactly when is an implementation detail. > at least that

Re: File not closed on exception

2009-10-19 Thread Ethan Furman
arve.knud...@gmail.com wrote: Hi I thought that file objects were supposed to be garbage-collected and automatically closed once they go out of scope, at least that's what I've been told by more merited Python programmers. I'm also quite sure that this is quite a common assumption in various pro

File not closed on exception

2009-10-19 Thread arve.knud...@gmail.com
Hi I thought that file objects were supposed to be garbage-collected and automatically closed once they go out of scope, at least that's what I've been told by more merited Python programmers. I'm also quite sure that this is quite a common assumption in various programs, at least given what opens