Closed
Description
Hi,
It is good not to use the default arguments while calling a function.
MCVE Code Sample
In file xarray/tests/test_conventions.py
# Your code here
329 @contextlib.contextmanager
330 def roundtrip(
331 self, data, save_kwargs={}, open_kwargs={}, allow_cleanup_failure=False332 ):
333 store = CFEncodedInMemoryStore()
334 data.dump_to_store(store, **save_kwargs)
Problem Description
Default arguments in Python are evaluated once when the function definition is executed. This means that the expression is evaluated only once when the function is defined and that the same value is used for each subsequent call. So if you are modifying the mutable default argument — a list, dict, etc., it will be modified for all future calls.
Metadata
Metadata
Assignees
Labels
No labels