Let’s look at an example:
def f(value, key, hash={}):
hash[value] = key
return hash
print(f('a', 1))
print(f('b', 2))
Which you probably expect to output:
{'a': 1}
{'b': 2}
But actually outputs:
{'a': 1}
{'a': 1, 'b': 2}
More Related Contents:
- Normal arguments vs. keyword arguments
- Pylint “unresolved import” error in Visual Studio Code
- Should wildcard import be avoided?
- PyLint “Unable to import” error – how to set PYTHONPATH?
- Why does it say that module pygame has no init member?
- How do I disable a Pylint warning?
- How do I create a Python function with optional arguments?
- How do I define a function with optional arguments?
- Instance attribute attribute_name defined outside __init__
- Is it possible to ignore one single specific line with Pylint?
- PyLint message: logging-format-interpolation
- Avoid Pylint warning E1101: ‘Instance of .. has no .. member’ for class with dynamic attributes
- Named tuple and default values for optional keyword arguments
- Unintentional trailing comma that creates a tuple
- How to check whether optional function parameter is set
- How do I get Pylint to recognize NumPy members?
- How to exclude Optional unset values from a Pydantic model using FastAPI?
- Pylint, PyChecker or PyFlakes? [closed]
- Imports failing in VScode for pylint when importing pygame
- pylint 1.4 reports E1101(no-member) on all C extensions
- Invoking Pylint programmatically
- How do I disable pylint unused import error messages in vs code
- pylint can’t find QWidget and QApplication
- ImportError : Attempted relative import with no known parent package [duplicate]
- No name ‘QApplication’ in module ‘PyQt5.QtWidgets’ error in Pylint
- How to run Pylint with PyCharm
- df.append() is not appending to the DataFrame
- CMD opens Windows Store when I type ‘python’
- Example of the right way to use QThread in PyQt?
- Subprocess timeout failure