&gt; The whole &quot;file handles&quot; can&#x27;t escape a certain scope sounds like what python&#x27;s with statement does.<p>It is incredibly easy to return a file handle out of a with statement. There is nothing in place other than programmer discipline preventing you from doing so, and your program blows up in... interesting ways.