traits.trait_base Module

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

Classes

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’.

class traits.trait_base.HandleWeakRef(object, name, value)[source]

Functions

traits.trait_base.strx(arg)[source]

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

traits.trait_base.class_of(object)[source]

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’).

traits.trait_base.add_article(name)[source]

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

traits.trait_base.user_name_for(name)[source]

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'.

traits.trait_base.traits_home()[source]

Gets the path to the Traits home directory.

traits.trait_base.verify_path(path)[source]

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

traits.trait_base.get_module_name(level=2)[source]

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

traits.trait_base.get_resource_path(level=2)[source]

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…]].

traits.trait_base.is_none(value)[source]
traits.trait_base.not_none(value)[source]
traits.trait_base.not_false(value)[source]
traits.trait_base.not_event(value)[source]
traits.trait_base.is_str(value)[source]