coady / multimethod

Multiple argument dispatching.
https://coady.github.io/multimethod
Other
284 stars 23 forks source link

Multi dispatch for methods #39

Closed otchita closed 3 years ago

otchita commented 3 years ago

Hello,

As I was using this library for multi dispatching for functions, I was wondering if the same functionality can be added to methods as well. It would look some like this:

class Test:

    @multidispatchmethod
    def meth(self, *args, **kwargs):
        ...

    @meth.register(int, float)
    def _(self, x: int, y: float):
        ...

    @meth.register(str, str)
    def _(self, x: str, y: str):
        ...

I would be open to work on this eventual feature 😄 .

coady commented 3 years ago

Hi. It already supports methods:

@meth.register
def _(self, x: int, y: float):
    ...