Skip to content

Using external Cast types

Nat Wilson edited this page Jul 3, 2014 · 1 revision

Functions and methods within narwhal can interact with externally-defined Cast-like and CastCollection-like objects that implement the correct interface. In order for external code to be recognized by narwhal, it must be registered with the narwhal.AbstractCast/narwhal.AbstractCastCollection meta-classes.

Example:

import narwhal

class MyCustomCast(object):
    [...]

class MyCustomCastCollection(object):
    [...]

narwhal.AbstractCast.register(MyCustomCast)
narwhal.AbstractCastCollection.register(MyCustomCastCollection)

This mechanism permits narwhal to interact with a wider variety of external code.