defaultdict(None)
defaultdict
requires a callable as argument that provides the default-value when invoked without arguments. None
is not callable. What you want is this:
defaultdict(lambda: None)
In this use case, don't use defaultdict
at all -- a plain dict
will do just fine:
states = {}
if new_state_1 != states.get("State 1"):
dispatch_transition()
The dict.get()
method returns the value for a given key, or a default value if the key is not found. The default value defaults to None
.