2 ms·
> default arg instances getting cached across calls That is not what is happening at all, logically or semantically. Effectively this is. # People not und
by njharman 6y ago
> default arg instances getting cached across calls
That is not what is happening at all, logically or semantically. Effectively this is.
# People not understanding when the
# function definition including arguments is evaluated.
mutable_instance = list()
def func(change_me=mutable_instance):
pass
- pansa2 6y agoWouldn’t something like this have been better? def func(change_me=None): if change_me is None: change_me = list() ...