Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17600

Re: nesting context managers

Date 2011-12-20 10:02 -0800
From Ethan Furman <ethan@stoneleaf.us>
Subject Re: nesting context managers
References <ash6s8-qj5.ln1@satorlaser.homedns.org> <nbr6s8-n86.ln1@satorlaser.homedns.org> <CAGEKe-1HzmQZU9tYwtH6W1DyRoRiSwCmojqRhfJ1MBr5LxO-=w@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3874.1324407140.27778.python-list@python.org> (permalink)

Show all headers | View raw


Rami Chowdhury wrote:
> On Tue, Dec 20, 2011 at 16:56, Ulrich Eckhardt
> <ulrich.eckhardt@dominolaser.com> wrote:
>> To be extra safe or in more complicated scenarios, I could wrap this in a
>> try-except and explicitly close those that were already created, but
>> normally I'd expect the garbage collector to do that for me ... or am I then
>> implicitly assuming a specific implementation?
> 
> I'm no expert but I believe the basic garbage collection behavior is
> part of the language, and it's only details of breaking cycles that
> are specific to CPython -- can anyone correct me if I'm wrong?

Garbage collection is part of the language, but how, and when, is 
implementation specific.

Resource management (beyond basic memory allocation) should be handled 
directly.  Python 3 encourages this by complaining if there were still 
open files when it shuts down.

~Ethan~

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

nesting context managers Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2011-12-20 15:15 +0100
  Re: nesting context managers Rami Chowdhury <rami.chowdhury@gmail.com> - 2011-12-20 16:25 +0000
  Re: nesting context managers Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2011-12-20 17:56 +0100
    Re: nesting context managers Rami Chowdhury <rami.chowdhury@gmail.com> - 2011-12-20 17:46 +0000
    Re: nesting context managers Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-20 11:46 -0700
    Re: nesting context managers Ethan Furman <ethan@stoneleaf.us> - 2011-12-20 10:02 -0800
    Re: nesting context managers Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-20 11:55 -0700

csiph-web