How can an optional parameter become required?
问题 Based on Disable global variable lookup in Python (and my own answer there), I have had problems when using a function with optional parameters such as in this minimal example: import types def noglobal(f): return types.FunctionType(f.__code__, {}) @noglobal def myFunction(x=0): pass myFunction() Essentially, it fails like this: Traceback (most recent call last): File "SetTagValue.py", line 10, in <module> myFunction() TypeError: myFunction() missing 1 required positional argument: 'x' Why is