Re:Five-minute Multimethods in Python
by radarsat1 on Wednesday December 07, 2011 @09:20AM
(#3323839)
Actually it's just checking the types at runtime, nothing much 'static' about it. This is pretty much the antithesis of duck typing, in fact. I could see it being useful, but I could also see it leading to confusion for people who expect Python's usual duck-typing behaviour when they pass their own types into a function.
Whoops you subclassed from a type for which this function has a multimethod defined? Gonna do something different.
On the other hand, in non-trivial programs there _are_ certainly occasions when you need to check the type, so using an elegant method like this isn't a bad compromise.
Whoops you subclassed from a type for which this function has a multimethod defined? Gonna do something different.
On the other hand, in non-trivial programs there _are_ certainly occasions when you need to check the type, so using an elegant method like this isn't a bad compromise.