skip to navigation
skip to content

Not Logged In

multimethod 0.4

Multiple argument dispatching.

Multiple argument dispatching

Call multimethod on a variable number of types. It returns a decorator which finds the multimethod of the same name, creating it if necessary, and adds that function to it. For example:

@multimethod(*types)
def func(*args):
    pass

func is now a multimethod which will delegate to the above function, when called with arguments of the specified types. If an exact match can't be found, the next closest method is called (and cached). If strict is enabled, and there are multiple candidate methods, a TypeError is raised. A function can have more than one multimethod decorator.

See tests for more example usage. Supported on Python 2.6 or higher, including Python 3.

Changes in 0.4:
  • Dispatch on python 3 annotations
 
File Type Py Version Uploaded on Size
multimethod-0.4.tar.gz (md5) Source 2013-11-11 3KB
  • Downloads (All Versions):
  • 6 downloads in the last day
  • 95 downloads in the last week
  • 457 downloads in the last month