[Python-ideas] For-loop variable scope: simultaneous possession and ingestion of cake
Jim Jewett
jimjjewett at gmail.com
Wed Oct 8 18:33:36 CEST 2008
On Tue, Oct 7, 2008 at 9:57 PM, Bruce Leban <bruce at leapyear.org> wrote:
> &aux is described here:
> http://www.lispworks.com/documentation/HyperSpec/Body/03_dae.htm
>
> this says it's equivalent to let* which is described here:
> http://www.lispworks.com/documentation/HyperSpec/Body/s_let_l.htm
> In short &aux and let* evaluates each expression, assigns it to a variable
> and then evaluates the next, etc. Default values in python are evaluated in
> like Lisp's let, not let*.
How do you figure? As nearly as I can tell, the only difference is
that let* is evaluated in order (left-to-right) instead of in
parallel.
Python parameters are also evaluated left-to-right, as nearly as I can tell.
>>> def f():
global var
var="from f"
>>> var="base"
>>> def h(): print "var is", var
>>> def g(a=f(), b=h()): print b
var is from f
This shows that the side effect of binding a was already present when
b was bound.
-jJ
More information about the Python-ideas
mailing list