bundles / traitlets 5.14.3 / traitlets / traitlets / observe
function
traitlets.traitlets:observe
source: /traitlets/traitlets.py :1080
Signature
def observe ( * names : Sentinel | str , type : str = change ) → ObserveHandler Summary
A decorator which can be used to observe Traits on a class.
Extended Summary
The handler passed to the decorator will be called with one change dict argument. The change dictionary at least holds a 'type' key and a 'name' key, corresponding respectively to the type of notification and the name of the attribute that triggered the notification.
Other keys may be passed depending on the value of 'type'. In the case where type is 'change', we also have the following keys: * owner : the HasTraits instance * old : the old value of the modified trait attribute * new : the new value of the modified trait attribute * name : the name of the modified trait attribute.
Parameters
*namesThe str names of the Traits to observe on the object.
type: str, kwarg-onlyThe type of event to observe (e.g. 'change')
Aliases
-
traitlets.observe