for example:
@singledispatch
def f(
a: str,
b: list | dict
)->None:
...
@f.register
def flist(
a: str,
b: list
)->None:
print("flist:",type(b))
@f.register
def fdict(
a: str,
b: dict
)->None:
print("fdict:",type(b))
a = "---"
b = [1,2]
f(a,b)
b = {1:2}
f(a,b)
My (apparently incorrect) understanding, is that this should print (I hope for obvious reasons):
flist: <class 'list'>
fdict: <class 'dict'>
but in fact, this prints:
fdict: <class 'list'>
fdict: <class 'dict'>
why does the first call to f redirect to 'fdict', despite 'b' being a list ?