[issue13585] Add contextlib.ExitStack

2018-04-11 Thread Jeroen Demeyer

Jeroen Demeyer  added the comment:

Follow-up: https://bugs.python.org/issue33265

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13585] Add contextlib.ExitStack

2018-04-11 Thread Jeroen Demeyer

Jeroen Demeyer  added the comment:

Why this?

_exit_wrapper.__self__ = cm

It seems that you are trying to create something which is exactly like a method 
except that it's not a method. Is there any reason to not use an actual method? 
It would actually simplify the code.

I ask because assigning __self__ might break after PEP 575.

--
nosy: +jdemeyer

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13585] Add contextlib.ExitStack

2012-05-21 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 8ef66c73b1e1 by Nick Coghlan in branch 'default':
Close #13585: add contextlib.ExitStack to replace the ill-fated 
contextlib.nested API
http://hg.python.org/cpython/rev/8ef66c73b1e1

--
nosy: +python-dev
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

___
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



[issue13585] Add contextlib.ExitStack

2012-05-01 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

Latest draft of API is here: 
http://contextlib2_dev.readthedocs.org/en/latest/index.html#contextlib2.ExitStack

An updated version of the I forgot I could use multiple context managers in a 
with statement example:

with ExitStack() as stack:
src = open(source)
stack.callback(src.close)
dest = open(destination, 'w')
stack.callback(dest.close)
copy(src, dest)

The example of opening a collection of files remains unchanged (aside from 
s/ContextStack/ExitStack/).

Also see: 
http://contextlib2_dev.readthedocs.org/en/latest/index.html#replacing-any-use-of-try-finally-and-flag-variables

--
assignee: rhettinger - ncoghlan
resolution: later - 
title: Add contextlib.CallbackStack - Add contextlib.ExitStack

___
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