[Python-ideas] Add contextlib.DummyContext
Ethan Furman
ethan at stoneleaf.us
Wed May 18 11:11:00 EDT 2016
On 05/18/2016 06:16 AM, Giampaolo Rodola' wrote:
> On Wed, May 18, 2016 at 1:36 AM, Devin Jeanpierre wrote:
>> with contextlib.ExitStack() as exit_stack:
>> if not bypass_lock:
>> exit_stack.enter_context(RedisLock())
>>
>> And similar.
>>
>> In fact, ExitStack can itself be used as a no-op context manager, if
>> you want.
>
> I didn't think about this. So yeah, my proposal is useless. Nevermind.
Not at all. It's a good use-case, and it helped introduce/remind us
about ExitStack (which I suspect is a hidden gem).
So thank you all! :)
--
~Ethan~
More information about the Python-ideas
mailing list