API Reference for Enthought Tool Suite 2.7.1

Ensures that a value assigned to a trait attribute is a list containing elements of a specified type, and that the length of the list is also within a specified range.

TraitList also makes sure that any changes made to the list after it is assigned to the trait attribute do not violate the list's type and length constraints. TraitList is the underlying handler for the predefined list-based traits.

For example:

class Card(HasTraits):
    pass
class Hand(HasTraits):
    cards = Trait([], TraitList(Trait(Card), maxlen=52))

This example defines a Hand class, which has a cards trait attribute, which is a list of Card objects and can have from 0 to 52 items in the list.

Inherits from

Attributes

Method summary

Methods

Copyright © 2002-2008 Enthought, Inc.