On 31 maj 2013, at 01:51, Łukasz Langa <luk...@langa.pl> wrote: > On 31 maj 2013, at 01:47, Łukasz Langa <luk...@langa.pl> wrote: > >> class State: >> def __init__(self): >> self.add.register(int, self.add_int) > > Ouch, I realized this is wrong just after I hit "Send". > self.add is a staticmethod so this registration will overload > on every instance. Which is obviously bad.
So, after some embarrassing head banging, here's the correct solution: https://gist.github.com/ambv/5682351 So, it *is* possible to make instance-level and class-level registration work with the existing @singledispatch code and a bit of plumbing. Obviously, all that is not necessary for actual static methods. Back to the point, though. I don't feel we should complicate the code, tests and documentation by introducing special handling for methods. In terms of pure type-driven single dispatch, we have a solution that was intentionally simple from the get-go. The next step will be predicate dispatch anyway ;)) What do you think? -- Best regards, Łukasz Langa WWW: http://lukasz.langa.pl/ Twitter: @llanga IRC: ambv on #python-dev _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com