puffbird.CallableContainer

class puffbird.CallableContainer(default_callable)[source]

Container of callables, that accept one argument.

Parameters
default_callablecallable

Default callable used when argument passed does not correspond to an assigned instance.

Notes

Each callable can be assigned to a specific instances using the add method. This method accepts a callable and a class or a tuple of class objects. When the container is called it will check if the single argument passed corresponds to an instance of the class objects and if so use the assigned callable with the argument passed.

Methods

__call__(x)

Check type of x and then use the appropriate callable.

add(a_callable, classes)

Add a new callable with allowed classes.