A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20110226/aaf0e84a/attachment.html below:

<div dir="ltr"><div class="gmail_quote">On Sat, Feb 26, 2011 at 4:39 PM, Nick Coghlan <span dir="ltr">&lt;<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On Sat, Feb 26, 2011 at 10:52 PM, cool-RR &lt;<a href="mailto:cool-rr@cool-rr.com">cool-rr@cool-rr.com</a>&gt; wrote:<br>
&gt; Hello,<br>
&gt; I noticed that the `TemporaryDirectory` context manager creates the folder<br>
&gt; on `__init__` rather than on `__enter__`, resulting in complexity, bugs, and<br>
&gt; hackarounds in `__del__`. I assume there&#39;s a good reason for this decision.<br>
&gt; What is it?<br>
<br>
</div></div>From the docstring: &quot;This has the same behavior as mkdtemp but can be<br>
used as a context manager.&quot; Like files, it *can* be used as a context<br>
manager, but doesn&#39;t have to be.<br>
<br>
Also, the complexity wouldn&#39;t go away even if the directory creation<br>
was delayed until the __enter__ invocation. People can still call<br>
__enter__ directly, so __del__ would still be obliged to try to clear<br>
things up as best it could.<br>
<br>
Cheers,<br>
Nick.</blockquote><div><br></div><div>I think that if someone calls `__enter__` directly, he takes the responsibility of calling `__exit__`, so we don&#39;t really have to help him with `__del__`.</div><div><br></div><div>
But other than that I understand the motivation for making it start on `__init__` rather then `__enter__`. I&#39;ll just make my own version of it that will work on `__enter__` instead.</div><div><br></div></div>Thanks,
<div>Ram.</div></div>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4