<?xml version="1.0" encoding='utf-8'?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Resource management (computing) - Page 17 - Wikipedia">
<p>
<a accesskey="1" href="page.php?w=Resource_management_(computing)&amp;p=16">1.Previous</a><br />
<a accesskey="3" href="page.php?w=Resource_management_%28computing%29&amp;p=18">3.Next</a>
</p>
<p>be paired correctly.</p>

<p>The resource leak can be resolved in languages that support a <code>finally</code> construction (like Python) by placing the body in a <code>try</code> clause, and the release in a <code>finally</code> clause:<syntaxhighlight lang="python">from typing import TextIO</syntaxhighlight></p>

<p>f: TextIO = open(filename)try:    ...finally:    f.close()This ensures correct release even if there is a return within the body or an exception thrown. Further, note that the acquisition occurs before the <code>try</code> clause,</p><p>
<a accesskey="1" href="page.php?w=Resource_management_(computing)&amp;p=16">1.Previous</a><br />
<a accesskey="3" href="page.php?w=Resource_management_%28computing%29&amp;p=18">3.Next</a>
</p>

<do type="prev" label="Search">
        <go href="search.wml"/>
</do>

</card>
</wml>
