On Sat, Aug 31, 2019 at 3:43 PM Piet van Oostrum wrote:
>
> There is a difference here with the construct that the OP mentioned:
>
> lines = open("foo.txt").readlines()
>
> In that case the file COULD be closed, but there is no guarantee. It depends
> on garbage collection.
> In your case t
> On 1 Sep 2019, at 17:57, MRAB wrote:
>
> On 2019-09-01 16:46, Barry wrote:
>>> On 31 Aug 2019, at 15:41, Manfred Lotz wrote:
>>> When you say COULD this sounds like it is a matter of luck. My thinking
>>> was that USUALLY the file will be closed after the statement because
>>> then the file
On Mon, Sep 2, 2019 at 3:02 AM MRAB wrote:
>
> On 2019-09-01 16:46, Barry wrote:
> >
> >
> >> On 31 Aug 2019, at 15:41, Manfred Lotz wrote:
> >>
> >> When you say COULD this sounds like it is a matter of luck. My thinking
> >> was that USUALLY the file will be closed after the statement because
>
On 2019-09-01 16:46, Barry wrote:
On 31 Aug 2019, at 15:41, Manfred Lotz wrote:
When you say COULD this sounds like it is a matter of luck. My thinking
was that USUALLY the file will be closed after the statement because
then the file handle goes out of scope.
It all depends on the way any
On Sun, 1 Sep 2019 16:46:44 +0100
Barry wrote:
> > On 31 Aug 2019, at 15:41, Manfred Lotz wrote:
> >
> > When you say COULD this sounds like it is a matter of luck. My
> > thinking was that USUALLY the file will be closed after the
> > statement because then the file handle goes out of scope.
> On 31 Aug 2019, at 15:41, Manfred Lotz wrote:
>
> When you say COULD this sounds like it is a matter of luck. My thinking
> was that USUALLY the file will be closed after the statement because
> then the file handle goes out of scope.
It all depends on the way any python implementation does
On Sat, 31 Aug 2019 16:37:23 +0200
Peter Otten <__pete...@web.de> wrote:
> Manfred Lotz wrote:
>
> > Hi there,
> > This is a beginner question.
> >
> > I learned that
> >
> > with open("foo.txt") as f:
> > lines = f.readlines()
> >
> > using the with-construct is the recommended way to
On Sat, 31 Aug 2019 15:43:41 +0200
Piet van Oostrum wrote:
> Max Zettlmeißl writes:
>
> > On Sat, Aug 31, 2019 at 2:22 PM Manfred Lotz
> > wrote:
> >>
> >> Could I use the latter as a substitute for the with-construct?
> >>
> >
> > You can't use the second statement as a proper substitute
Manfred Lotz wrote:
> Hi there,
> This is a beginner question.
>
> I learned that
>
> with open("foo.txt") as f:
> lines = f.readlines()
>
> using the with-construct is the recommended way to deal with files
> making sure that close() always happens.
>
> However, I also could do:
>
>
On 2019-08-31, Manfred Lotz wrote:
> Hi there,
> This is a beginner question.
>
> I learned that
>
> with open("foo.txt") as f:
> lines = f.readlines()
>
> using the with-construct is the recommended way to deal with files
> making sure that close() always happens.
More importantly, it m
Max Zettlmeißl writes:
> On Sat, Aug 31, 2019 at 2:22 PM Manfred Lotz wrote:
>>
>> Could I use the latter as a substitute for the with-construct?
>>
>
> You can't use the second statement as a proper substitute for the first one.
>
> With the context manager, it is ensured that the file is close
On Sat, Aug 31, 2019 at 2:22 PM Manfred Lotz wrote:
>
> Could I use the latter as a substitute for the with-construct?
>
You can't use the second statement as a proper substitute for the first one.
With the context manager, it is ensured that the file is closed. It's
more or less equal to a "fin
12 matches
Mail list logo