<div dir="ltr">Lisp's let: evaluate, evaluate, evaluate, assign, assign, assign<br>Lisp's let*: evaluate, assign, evaluate, assign, evaluate, assign<br><br>In Python as in Lisp, the side effects of the first evaluation are visible to the second but in Python and Lisp's let (vs. let*) the assignment of the first variable doesn't happen until after all the expressions have been evaluated.<br>
<br>>>> def f(i=0, j=i+1):<br> pass<br><br>Traceback (most recent call last):<br> File "<pyshell#2>", line 1, in <module><br> def f(i=0, j=i+1):<br>NameError: name 'i' is not defined<br>
<br><br><div class="gmail_quote">On Wed, Oct 8, 2008 at 9:33 AM, Jim Jewett <span dir="ltr"><<a href="mailto:jimjjewett@gmail.com">jimjjewett@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Tue, Oct 7, 2008 at 9:57 PM, Bruce Leban <<a href="mailto:bruce@leapyear.org">bruce@leapyear.org</a>> wrote:<br>
> &aux is described here:<br>
> <a href="http://www.lispworks.com/documentation/HyperSpec/Body/03_dae.htm" target="_blank">http://www.lispworks.com/documentation/HyperSpec/Body/03_dae.htm</a><br>
><br>
> this says it's equivalent to let* which is described here:<br>
> <a href="http://www.lispworks.com/documentation/HyperSpec/Body/s_let_l.htm" target="_blank">http://www.lispworks.com/documentation/HyperSpec/Body/s_let_l.htm</a><br>
> In short &aux and let* evaluates each expression, assigns it to a variable<br>
> and then evaluates the next, etc. Default values in python are evaluated in<br>
> like Lisp's let, not let*.<br>
<br>
<br>
</div>How do you figure? As nearly as I can tell, the only difference is<br>
that let* is evaluated in order (left-to-right) instead of in<br>
parallel.<br>
<br>
Python parameters are also evaluated left-to-right, as nearly as I can tell.<br>
<br>
>>> def f():<br>
global var<br>
var="from f"<br>
>>> var="base"<br>
>>> def h(): print "var is", var<br>
<br>
>>> def g(a=f(), b=h()): print b<br>
<br>
var is from f<br>
<br>
This shows that the side effect of binding a was already present when<br>
b was bound.<br>
<font color="#888888"><br>
-jJ<br>
</font></blockquote></div><br></div>