<br><br><div class="gmail_quote"><div dir="ltr">On Wed, May 18, 2016, 10:12 Ethan Furman <<a href="mailto:ethan@stoneleaf.us">ethan@stoneleaf.us</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 05/18/2016 06:16 AM, Giampaolo Rodola' wrote:<br>
> On Wed, May 18, 2016 at 1:36 AM, Devin Jeanpierre wrote:<br>
<br>
>> with contextlib.ExitStack() as exit_stack:<br>
>> if not bypass_lock:<br>
>> exit_stack.enter_context(RedisLock())<br>
>><br>
>> And similar.<br>
>><br>
>> In fact, ExitStack can itself be used as a no-op context manager, if<br>
>> you want.<br>
><br>
> I didn't think about this. So yeah, my proposal is useless. Nevermind.<br>
<br>
Not at all. It's a good use-case, and it helped introduce/remind us<br>
about ExitStack (which I suspect is a hidden gem).<br>
<br>
So thank you all! :)<br></blockquote></div><div><br></div><div>Python 3.6 also has a context manager ABC so you could also use that in 2 lines for a dummy context manager.</div><div><br></div><div>-brett</div><div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
--<br>
~Ethan~<br>
<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>