Imagine following:
class MyDummyNumber:
...
@dispatch(int)
def __add__(self, i):
...
@dispatch(MyDummyNumber)
def __add__(self, m):
...
As expected, we have NameError: name 'MyDummyNumber' is not defined here, which is not multipledispatch issue, but Python one.
There are many ugly ways to workaround this. Then beautiful way is needed!
However multipledispatch works during runtime, so I think that it is potentially possible to specify "current class" during dispatching definition, like following:
@dispatch(multipledispatch.current_class)
def __add__(self, m):
...