MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / get_or_default

Function get_or_default

example_code/item_124.py:120–123  ·  view source on GitHub ↗
(value, default)

Source from the content-addressed store, hash-verified

118print("Example 9")
119try:
120 def get_or_default(value, default):
121 if value is not None:
122 return value
123 return value
124
125 found = get_or_default(3, 5)
126 assert found == 3

Callers 1

item_124.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected