Optional type-checking, data dependencies, and event notifications for Python
Python C Batchfile
Latest commit dbc8c47 Jun 22, 2016 @corranwebster corranwebster committed on GitHub Merge pull request #316 from robmcmullen/master
Additional code to locate resources within py2app/py2exe bundles
Failed to load latest commit information.
fixers Description line for FixUnicodeMethods fixer. May 7, 2014
traits Merge remote-tracking branch 'upstream/master' Jun 20, 2016
.travis.yml Only build on pushes to master. Jun 7, 2016
README.rst update readme with documentation building dependencies May 12, 2015
appveyor.yml do not use wheels when upgrading pip Jan 21, 2016
image_LICENSE.txt fixed imports Apr 20, 2011
image_LICENSE_Eclipse.txt ENH: cleanup Oct 15, 2010
travis-ci-requirements.txt fix python_version comparison Jul 21, 2015


traits: explicitly typed attributes for Python


Build status Coverage status

The Traits project is at the center of all Enthought Tool Suite development and has changed the mental model used at Enthought for programming in the already extremely efficient Python programming language. We encourage everyone to join us in enjoying the productivity gains from using such a powerful approach.

The Traits project allows Python programmers to use a special kind of type definition called a trait, which gives object attributes some additional characteristics:

  • Initialization: A trait has a default value, which is automatically set as the initial value of an attribute before its first use in a program.
  • Validation: The type of a trait attribute is explicitly declared. The type is evident in the code, and only values that meet a programmer-specified set of criteria (i.e., the trait definition) can be assigned to that attribute.
  • Delegation: The value of a trait attribute can be contained either in the defining object or in another object delegated to by the trait.
  • Notification: Setting the value of a trait attribute can notify other parts of the program that the value has changed.
  • Visualization: User interfaces that allow a user to interactively modify the value of a trait attribute can be automatically constructed using the trait's definition. (This feature requires that a supported GUI toolkit be installed. If this feature is not used, the Traits project does not otherwise require GUI support.)

A class can freely mix trait-based attributes with normal Python attributes, or can opt to allow the use of only a fixed or open set of trait attributes within the class. Trait attributes defined by a class are automatically inherited by any subclass derived from the class.


Traits has the following optional dependencies:

  • NumPy to support the trait types for arrays.
  • Traitsui to support Gui Views.

To build the full documentation one needs:

  • sphinx > 1.2.3
  • mock (optional if traitsui is not available)