Author ethan smith
Recipients ethan smith
Date 2017-12-19.22:23:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Consider the following:

from functools import singledispatch

class Dispatch:
    def foo(self, a):
        return a

    def _(self, a):
        return "int"

    def _(self, a):
        return "str"

cls = Dispatch()  # 3'hm')  # 'hm'

I find this quite unintuitive. Essentially, since singledispatch dispatches based solely on a functions first argument, it is useless on methods unless one wraps it and modifies how it uses the internal wrapper function. I believe this should be relatively easy to fix with adding a check of inspect.ismethod and then modifying the number of the checked argument where appropriate.

I'm happy to write a patch if this change is seen as a good idea.
Date User Action Args
2017-12-19 22:23:08ethan smithsetrecipients: + ethan smith
2017-12-19 22:23:08ethan smithsetmessageid: <>
2017-12-19 22:23:08ethan smithlinkissue32380 messages
2017-12-19 22:23:08ethan smithcreate