3 ms·
This translates into fn = lambda y=[y]: y.push(7); return y if you accept the ; to separate statements, as the lambda in python is syntactically only allo
by Tyr42 14y ago
This translates into
fn = lambda y=[y]: y.push(7); return y
if you accept the ; to separate statements, as the lambda in python is syntactically only allowed to contain one statement.
(The introduction of the variable x into the example is not important for the behavior of default arguments, however, it is important for a separate issue. I've stripped it out here.)