<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Diez B. Roggisch wrote:
<blockquote cite="mid:7823bvF1k6ml9U1@mid.uni-berlin.de" type="cite">
<pre wrap="">John wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I'm okay with init, but it seems to me that enter is redundant since it
appears that anything you want to execute in enter can be done in init.
</pre>
</blockquote>
<pre wrap=""><!---->
About what are you talking?
Diez
</pre>
</blockquote>
Presumably, the 'with' statement.
<a class="moz-txt-link-freetext" href="http://www.python.org/dev/peps/pep-0343/">http://www.python.org/dev/peps/pep-0343/</a><br>
<blockquote>
<div class="yui-u first">
<p><strong>__enter__</strong>(self)</p>
<p>Enter the runtime context related to this object. The <a
href="http://effbot.org/pyref/with.htm"><strong>with</strong></a>
statement
will bind this method’s return value to the target(s) specified in the
<a href="http://effbot.org/pyref/as.htm"><strong>as</strong></a>
clause of the statement, if any.</p>
</div>
</blockquote>
<br>
Unlike __init__, __enter__ can return a value, which is assigned to
the variable (or tuple) following the 'as' keyword:<br>
<pre> with EXPR as VAR:
BLOCK
</pre>
Also, the object used in a with statement can be constructed prior to
the with statement. The __init__ method is called when the object is
initialized, but the __enter__ method is called when the context is
entered (i.e. when the 'with' statement is invoked).<br>
<br>
Ken<br>
<br>
</body>
</html>