Skip to content

Provide a way to reference current class for intstance methods #95

Description

@dluciv

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):
        ...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions