Closed peteut closed 5 years ago
Regarding multimethod.multimethod w/ arity of 1 consider this:
multimethod.multimethod
from multimethod import multimethod def clone_of_default(x): raise NotImplementedError("no implementation for {} found".format(type(x))) clone_of = multimethod(clone_of_default) clone_of[(int,)] = lambda x: int(x)
Adding a method like, which I tried first:
clone_of[int] = lambda x: int(x)
yields TypeError: 'type' object is not iterable.
TypeError: 'type' object is not iterable
What is the desired behaviour for arity 1?
Ok, my bad. It's according the spec.
The parens can be omitted too.
clone_of[int,]
The parens can be omitted too. clone_of[int,]
Good to know, thanks!
Regarding
multimethod.multimethod
w/ arity of 1 consider this:Adding a method like, which I tried first:
yields
TypeError: 'type' object is not iterable
.What is the desired behaviour for arity 1?