API Reference for Enthought Tool Suite 2.7.1

Ensures that trait attribute values belong to a specified Python class or type.

TraitInstance is the underlying handler for the predefined trait Instance and the elements of ListInstance.

Any trait that uses a TraitInstance handler ensures that its values belong to the specified type or class (or one of its subclasses). For example:

class employee(HasTraits):
    manager = Trait(None, TraitInstance(Employee, True))

This example defines a class Employee, which has a manager trait attribute, which accepts either None or an instance of Employee as its value.

TraitInstance ensures that assigned values are exactly of the type specified (i.e., no coercion is performed).

Inherits from

Attributes

Inherited from base classes

Method summary

Inherited from base classes

Methods

Copyright © 2002-2008 Enthought, Inc.