[Python-ideas] Explicit variable capture list

Terry Reedy tjreedy at udel.edu
Wed Jan 20 13:58:46 EST 2016


On 1/20/2016 11:48 AM, Guido van Rossum wrote:
> But 'shared' and 'local' are both the wrong words to use here. Also
> probably this should syntactically be tied to the function header so the
> time of evaluation is clear(er).

Use ';' in the parameter list, followed by name=expr pairs.  The 
question is whether names after are initialized local variables, subject 
to rebinding at runtime, or named constants, with the names replaced by 
the values at definition time.  In the former case, a type hint could by 
included.  In the latter case, which is much better for optimization, 
the fixed object would already be typed.

def f(int a, int b=1; int c=2) => int


-- 
Terry Jan Reedy



More information about the Python-ideas mailing list