<div dir="ltr"><br><br><div class="gmail_quote">On Wed, Oct 8, 2008 at 6:08 AM, Jan Kanis <span dir="ltr"><<a href="mailto:jan.kanis@phil.uu.nl">jan.kanis@phil.uu.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d">On 06/10/2008, Arnaud Delobelle <<a href="mailto:arnodel@googlemail.com">arnodel@googlemail.com</a>> wrote:<br>>  for a[0] in range(10):<br>
>     lst.append(lambda: a[0])<br>
>  for f in lst:<br>
>     print(f())<br>
<br>
</div>But I think this would be a better solution:<br>
2) Treat location specifiers other than local and global variables<br>
(variables you can write down without using dots or square brackets)<br>
the same as they are treated today. In that case, both loops would<br>
print ten times 9. I would want to argue this is the better approach,<br>
because when you write down a[0] you are specifically thinking of a<br>
and a[0] in terms of objects, while when you use a local variable you<br>
just need some place to store a temporary result, and not be bothered<br>
with it any more than absolutely necessary.</blockquote><div><br></div><div>I don't think this is better. Not that I'm proposing we add macros to the language but if we did then</div><div><br></div><div>    macro find(a, x, i):</div>
<div>        for i in range(len(x)):</div><div>            if x[i]:</div><div>                return lambda: x[i]</div><div><br></div><div>would operate differently for find(a, x, i) and find(a, x, i[0]). I think that's a bad idea.</div>
<div><br></div><div>--- Bruce</div></div></div>