Example 1 — Apply User Overrides to Default Settings
Merge an overrides dict into the defaults, then adjust two more values with keyword arguments.
settings = {"debug": False, "port": 8080, "host": "localhost"}
overrides = {"port": 9000, "workers": 4}
result = settings.update(overrides)
print(result)
print(settings)
settings.update(debug=True, host="0.0.0.0")
print(settings)
print(overrides) How It Works
- No return value.
update()works in place, soresultisNone. - Override wins.
portkeeps its second position but now holds 9000, and the brand-newworkerskey is appended at the end. - Keyword form.
debug=True, host="0.0.0.0"become the string keys'debug'and'host', replacing their old values. - Source untouched. The
overridesdict is only read, so it prints exactly as it was created.

