<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
> The real problem is that this code is not idiomatic Python, especially if<br>
> you want it to be reasonably fast:<br>
><br>
> � lst = []<br>
> � for i in range(100):<br>
> � � � lst.append(i*i)<br>
><br>
> Why not:<br>
><br>
> lst = [i*i for i in range(100)]<br>
><br>
> If the "append" pattern is complex, just "preallocate" like this:<br>
><br>
> lst = [0] * 100<br>
><br>
> And then fill it.<br>
><br>
> Eli<br></div></div></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
>How would you replicate the behavior of __exit__ in Christian's example?<br></div></div>
<br></blockquote><div><br></div><div>Why would I want to replicate it?<br><br></div><div>Eli<br><br></div></div></div></div>