Nikolaus Rath <nikol...@rath.org> added the comment:

On 12/11/2011 10:17 PM, Raymond Hettinger wrote:
> 
> Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:
> 
> '''
> Example code:
> 
> with CleanupManager() als mngr:
>     tmpdir = tempfile.mkdtemp()
>     mngr.register(shutil.rmtree(tmpdir)) <-- this makes the call right away
>     # do stuff with tmpdir
> '''

Oh, of course. That is fixed in the patch. I couldn't find a way to edit
the message in the tracker.

> The part of my note that should be clear is that the idea and code need to 
> prove itself before being added to the standard library.  So far, there has 
> been zero demand for this and I've not seen code like it being used in the 
> wild.  AFAICT, it is not demonstrably better than a straight-forward 
> try/finally.

I think it has the same advantages over try...finally as any use of
'with' has. CleanupManager would allow to use 'with' instead of
'try..finally' in many cases where this is currently not possible, so
unless the introduction of 'with' itself was a mistake, I think this is
just taking a step along the path that has already been chosen.

Best,

   -Nikolaus

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13585>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to