Note
This documentation is for a development version of Traitlets. There may be significant differences from the latest stable release.
Utils¶
A simple utility to import something by its string name.
-
traitlets.
import_item
(name)¶ Import and return
bar
given the stringfoo.bar
.Calling
bar = import_item("foo.bar")
is the functional equivalent of executing the codefrom foo import bar
.Parameters: name (string) – The fully qualified name of the module/package being imported. Returns: mod – The module that was imported. Return type: module object
Links¶
-
class
traitlets.
link
(source, target)¶ Link traits from different objects together so they remain in sync.
Parameters: - source ((object / attribute name) pair) –
- target ((object / attribute name) pair) –
Examples
>>> c = link((src, 'value'), (tgt, 'value')) >>> src.value = 5 # updates other objects as well
-
class
traitlets.
directional_link
(source, target, transform=None)¶ Link the trait of a source object with traits of target objects.
Parameters: Examples
>>> c = directional_link((src, 'value'), (tgt, 'value')) >>> src.value = 5 # updates target objects >>> tgt.value = 6 # does not update source object