This is unnecessarily complicated -- we can boil down your question to a few lines:
default = "Before"
def foo(bar=default):
print(bar)
foo() # "Before"
default = "After"
foo() # "Before"
The behavior it seems you expect is that after default = "After", calling foo() will print "After". But it continues to print "Before".
Python will evaluate the default argument for a function once and "lock it in". Reassigning the name of default to something else later has no effect (as we see in the snippet above).
Instead, you can use an approach that's commonly suggested when people want lists as default arguments:
default = "Before"
def foo(bar=None):
if bar is None:
bar = default
print(bar)
foo() # "Before"
default = "After"
foo() # "After"
In this case, you're not trying to change the default argument, but rather change what is assigned to bar when no argument is specified. Each time you call foo() with no argument, it'll be assigned None and then the logic inside the function will look up and use the value of the global default.
def d(i=None):and then inside the function,if i is None: i = c. This is for the same reason that using an empty list as a default argument can cause "unexpected" results.cin the moduleb, but thedfunction in modulebhas already been parsed and evaluated and its default for the argumentiwas already set toFalse. Python would be significantly slower if it had to always re-evaluate its function signatures.STRICT = Truein handle_error(strict=STRICT) and lethandle_errorraise error.