<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Python on Steady Monkey</title><link>https://steadymonkey.eu/tags/python/</link><description>Recent content in Python on Steady Monkey</description><generator>Hugo</generator><language>en-gb</language><lastBuildDate>Sun, 05 Jan 2020 18:43:10 +0000</lastBuildDate><atom:link href="https://steadymonkey.eu/tags/python/index.xml" rel="self" type="application/rss+xml"/><item><title>A reentrant context manager in Python</title><link>https://steadymonkey.eu/blog/a-reentrant-context-manager-in-python/</link><pubDate>Sun, 05 Jan 2020 18:43:10 +0000</pubDate><guid>https://steadymonkey.eu/blog/a-reentrant-context-manager-in-python/</guid><description>&lt;p&gt;A Python context manager caters for the boilerplate wrapping a resource to offer safety and convenient (re-)use.
This protocol ensures that once the context is initialised, it will be torn down whatever happens.
Examples of resource handling are input/output operations, session management, thread locking, etc.
In this article, we will take a focus peek at one &amp;ldquo;&lt;a href="https://www.python.org/dev/peps/pep-0020/#the-zen-of-python"&gt;honking great idea&lt;/a&gt; 



&lt;a href="https://web.archive.org/web/20191225084248/https://www.python.org/dev/peps/pep-0020/#the-zen-of-python" title="2019-12-25 archived copy of https://www.python.org/dev/peps/pep-0020/#the-zen-of-python" class="archive-link" target="_blank"&gt;(archived)&lt;/a&gt;
&amp;rdquo;: a &lt;strong&gt;reentrant context manager&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;There has been &lt;a href="http://johnj.com/intro-to-context-managers-in-python.html"&gt;many&lt;/a&gt; &lt;a href="https://book.pythontips.com/en/latest/context_managers.html"&gt;articles&lt;/a&gt; 



&lt;a href="https://web.archive.org/web/20191228102745/https://book.pythontips.com/en/latest/context_managers.html" title="2019-12-28 archived copy of https://book.pythontips.com/en/latest/context_managers.html" class="archive-link" target="_blank"&gt;(archived)&lt;/a&gt;
 and pages of &lt;a href="https://en.wikibooks.org/wiki/Python_Programming/Context_Managers"&gt;documentation&lt;/a&gt; 



&lt;a href="https://web.archive.org/web/20191031175507/https://en.wikibooks.org/wiki/Python_Programming/Context_Managers" title="2019-10-31 archived copy of https://en.wikibooks.org/wiki/Python_Programming/Context_Managers" class="archive-link" target="_blank"&gt;(archived)&lt;/a&gt;
 to explain why context managers are a good thing, and why you would want to &lt;a href="https://jeffknupp.com/blog/2016/03/07/python-with-context-managers/"&gt;always handle your resources&lt;/a&gt; 



&lt;a href="https://web.archive.org/web/20190917131000/https://jeffknupp.com/blog/2016/03/07/python-with-context-managers/" title="2019-09-17 archived copy of https://jeffknupp.com/blog/2016/03/07/python-with-context-managers/" class="archive-link" target="_blank"&gt;(archived)&lt;/a&gt;
 with them.&lt;/p&gt;</description></item></channel></rss>