5 ms·
The PEP seems entirely focused on bound checking and performing functions on variables in the function definition. I'm not sure it handles the use case op is t
by georgyo 5y ago
The PEP seems entirely focused on bound checking and performing functions on variables in the function definition.
I'm not sure it handles the use case op is talking about.
IE
def foo(bar=list()):
# this creates a mutable list shard by all calls of the function. Very unlikely something you want.
Maybe the pep would allow for
def foo(bar=>list()):
But the pep does not address this use case at all
- meowface 5y agoEven though the PEP doesn't explicitly mention mutable default arguments, I'm pretty sure it's intended for this use case, as well. It should address this issue. >Function parameters can have default values which are calculated during function definition and saved. This proposal introduces a new form of argument default, defined by an expression to be evaluated at function call time.