Content deleted Content added
FireflyBot (talk | contribs) m (BOT) Substituting Template:Date - should not be used in article space. |
|||
Line 120:
</syntaxhighlight>
Similarly, the [[Python (programming language)|Python]] language has a <code>with</code> statement that can be used to similar effect with a ''context manager'' object. The ''context manager protocol'' requires implementing <code>__enter__</code> and <code>__exit__</code> methods which get automatically called by the <code>with</code> statement construct, to prevent duplication of code that would otherwise occur with the <code>try</code>/<code>finally</code> pattern.<ref>{{cite web |author=[[Guido van Rossum]], Nick Coghlan |date=
<syntaxhighlight lang="python">
with resource_context_manager() as resource:
|