Skip to main content

traits: explicitly typed attributes for Python

http://github.enthought.com/traits

Build 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 has the following optional dependencies:

  • Numpy to support the trait types for arrays.

Metadata

Release files for traits 4.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for traits 4.4.0
File Size Uploaded
traits-4.4.0.tar.gz 226.3 kB Details

Release files / traits-4.4.0.tar.gz

Download URL traits-4.4.0.tar.gz
Size 226.3 kB
Tags Source
SHA-256 checksum
How to use checksums
737e710e9cbcd087d5b5dee9928447b5592049900757b55a2802ee2e4336c49c
BLAKE2b-256 checksum
How to use checksums
7b5f76da6c50930b1f334bf0121eb99ffec9b2640622a508019f37f90e5d648c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

7.2.0

49 release files

7.1.0

49 release files

7.0.2

49 release files

7.0.1

49 release files

7.0.0

13 release files

6.4.1

59 release files

6.4.0

34 release files

6.3.2

34 release files

6.3.1

34 release files

6.2.0

21 release files

6.1.1

1 release file

6.1.0

1 release file

6.0.0

1 release file

5.2.0

1 release file

5.1.2

1 release file

5.1.1

1 release file

5.1.0

1 release file

5.0.0

1 release file

4.6.0

3 release files

4.5.0

1 release file

This release

4.4.0 This release

1 release file

4.3.0

4.2.0

4.1.0

4.0.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page