On 2019-03-20, ast wrote:
In the following snippet, a file is opened but
without any variable referring to it.
So the file can't be closed.
[line.split(":")[0]
for line in open('/etc/passwd')
if line.strip() and not line.startswith("#")]
What do you think about this practice ?
As other
On Thu, Mar 21, 2019 at 1:16 AM Grant Edwards wrote:
>
> On 2019-03-20, ast wrote:
> > Hello
> >
> > In the following snippet, a file is opened but
> > without any variable referring to it.
> > So the file can't be closed.
> >
> > [line.split(":")[0]
> > for line in open('/etc/passwd')
> > if
On 2019-03-20, ast wrote:
> Hello
>
> In the following snippet, a file is opened but
> without any variable referring to it.
> So the file can't be closed.
>
> [line.split(":")[0]
> for line in open('/etc/passwd')
> if line.strip() and not line.startswith("#")]
>
> What do you think about this
ast wrote:
> Hello
>
> In the following snippet, a file is opened but
> without any variable referring to it.
> So the file can't be closed.
The file will be closed implicitly when the file object gets garbage-
collected:
$ python3
Python 3.4.3 (default, Nov 12 2018, 22:25:49)
[GCC 4.8.4] on l
Hello
In the following snippet, a file is opened but
without any variable referring to it.
So the file can't be closed.
[line.split(":")[0]
for line in open('/etc/passwd')
if line.strip() and not line.startswith("#")]
What do you think about this practice ?
--
https://mail.python.org/mailm
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
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
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
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
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
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,
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
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
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
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
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
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
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
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
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
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
21 matches
Mail list logo