[Python-ideas] For-loop variable scope: simultaneous possession and ingestion of cake

Jim Jewett jimjjewett at gmail.com
Wed Oct 8 02:39:21 CEST 2008

On 2008/10/6 Terry Reedy <tjreedy at udel.edu> wrote:

> you want immanetized expressions to be evaluated
> as the same time the default arg expressions are,
> which is when the def/lambda is executed to create
> a function object.  The only difference between them
> and default args is that they could not be replaced
> by the function call, which is precise the problem with
> default pseudoargs. Call them constants defined
> at definition time rather than as compilation time.

I have some vague memory that these might be called &aux variables in
Common Lisp.

> Do you want the constants to be names or anonymous  --
> which is to say, would there values appear in locals()?
> If named, their expressions could/should appear in the
> header with a syntax similar to but somehow
> different from default args.  A possibility:
>    ...lambda $i=i: i

Would giving them a __name and marking them as keyword-only meet the
goal?  (As best I can tell, it does for methods, but not for top-level
functions, because of the way __mangling works.)


More information about the Python-ideas mailing list