Skip to main content

Observable typed attributes for Python classes

Project description

http://docs.enthought.com/traits

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.

Dependencies

Traits requires Python >= 3.5.

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 version 1.8 or later.

  • The Enthought Sphinx Theme. (A version of the documentation can be built without this, but some formatting may be incorrect.)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

traits-6.1.1.tar.gz (567.0 kB view details)

Uploaded Source

File details

Details for the file traits-6.1.1.tar.gz.

File metadata

  • Download URL: traits-6.1.1.tar.gz
  • Upload date:
  • Size: 567.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for traits-6.1.1.tar.gz
Algorithm Hash digest
SHA256 807da52ee0d4fc1241c8f8a04d274a28d4b23d3a5f942152497d19405482d04f
MD5 85073940f51f6cb90f7024c0d6058730
BLAKE2b-256 94d4be3765c4c1ada555a91daa5cc9df3b6c2557ec4b55ba181c23ef5682e1f8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page