#強制使用浮點數,
typing可以使用Union
但dispatch不行,
會出現TypeError
Traceback (most recent call last):
File “c:\Python\RF Stable\untitled0.py”, line 7, in <module>
def myFunc(a: Union[float, int], b: Union[float, int]) -> Union[float, int]:
File “C:\ProgramData\Anaconda\lib\site-packages\multipledispatch\core.py”, line 68, in _
dispatcher.add(types, func)
File “C:\ProgramData\Anaconda\lib\site-packages\multipledispatch\dispatcher.py”, line 222, in add
raise TypeError(“Tried to dispatch on non-type: %s\n”
TypeError: Tried to dispatch on non-type: typing.Union[float, int]
In signature: <typing.Union[float, int], typing.Union[float, int]>
In function: myFunc