trait_base Module

Defines common, low-level capabilities needed by the Traits package.


traits.trait_base.Uninitialized = <uninitialized>

When the first reference to a trait is a ‘get’ reference, the default value of the trait is implicitly assigned and returned as the value of the trait. Because of this implicit assignment, a trait change notification is generated with the Uninitialized object as the ‘old’ value of the trait, and the default trait value as the ‘new’ value. This allows other parts of the traits package to recognize the assignment as the implicit default value assignment, and treat it specially.

traits.trait_base.Undefined = <undefined>

Singleton object that indicates that a trait attribute has not yet had a value set (i.e., its value is undefined). This object is used instead of None, because None often has other meanings, such as that a value is not used. When a trait attribute is first assigned a value, and its associated trait notification handlers are called, Undefined is passed as the old parameter, to indicate that the attribute previously had no value.

traits.trait_base.Missing = <missing>[source]

Singleton object that indicates that a method argument is missing from a type-checked method signature.

traits.trait_base.Self = <self>[source]

Singleton object that references the current ‘object’.



Wraps the built-in str() function to raise a TypeError if the argument is not of a type in StringTypes.


Returns a string containing the class name of an object with the correct indefinite article (‘a’ or ‘an’) preceding it (e.g., ‘an Image’, ‘a PlotValue’).


Returns a string containing the correct indefinite article (‘a’ or ‘an’) prefixed to the specified string.


Returns a “user-friendly” version of a string, with the first letter capitalized and with underscore characters replaced by spaces. For example, user_name_for('user_name_for') returns 'User name for'.


Gets the path to the Traits home directory.


Verify that a specified path exists, and try to create it if it does not exist.


Returns the name of the module that the caller’s caller is located in.


Returns a resource path calculated from the caller’s stack.

traits.trait_base.xgetattr(object, xname, default=<undefined>)[source]

Returns the value of an extended object attribute name of the form: name[.name2[.name3...]].

traits.trait_base.xsetattr(object, xname, value)[source]

Sets the value of an extended object attribute name of the form: name[.name2[.name3...]].