Table of Contents

Class: Signature ./src/peak/util/dispatch.py

A rule that matches positional type signatures based on issubclass

A Signature is a tuple of types or classes (i.e. "new-style" or "classic" classes) that represent the types of positional arguments to a function. It implements the IRule interface and can therefore be used as a rule in a Dispatch instance (such as a GenericFunction or MultiMethod). A Signature "matches" keys that are a sequence of the same length as itself, with every member of the sequence being the same as, or a subclass of, the corresponding member of the Signature.

Note that because signatures are tuples of classes, MultiMethod and GenericFunction objects must always be called with a fixed number of positional arguments, although keyword arguments may optionally be supplied as well. If you wish to support default arguments or want to supply keyword arguments that will be used as part of the dispatching, you'll need to create a wrapper function that supplies the defaults and accepts the keywords, then calls the MultiMethod or GenericFunction with the fixed positional arguments and any additional keyword arguments.

Base Classes   
tuple
Methods   
__contains__
__new__
  __contains__ 
__contains__ ( self,  value )

Does value (a types tuple or Signature) match this signature?

Exceptions   
DispatchError( "Can't compare signatures of different lengths", self, value )
  __new__ 
__new__ ( klass,  *typesOrClasses )

Signature(*typesOrClasses)
create a new signature
Exceptions   
DispatchError( "Signatures must be made of types or classes", t )

Table of Contents

This document was automatically generated on Tue Feb 17 19:55:52 2004 by HappyDoc version 2.1