hio.base.hier.needing
hio.base.hier.needing Module
Provides hierarchical action support
Module Contents
- class hio.base.hier.needing.Need(*, expr='True', hold=None, **kwa)
Bases:
hio.hioing.MixinNeed is conditional callable class whose callable returns a boolean. The calling it evaluates a need expression. May be used as the transition condition of a Gact.
Attributes:
hold (Hold): data shared by boxwork
- Properties:
expr (str): evaluable boolean expression. compiled (bool): True means ._code holds compiled ._expr; False means not yet compiled
- Hidden:
_expr (str): evaluable boolean expression. _code (None|CodeType): compiled evaluable boolean expression .expr; None means not yet compiled from .expr
- Compilation Notes:
The need returned by an
on()call keeps the string expression because compiled code objects are not pickleable. In multiprocessing, the child process recompiles the expression from the string form. Keeping the string representation also helps debugging and introspection.- Expression Syntax Notes:
His a local reference toself.holdduring evaluation. Need expressions can use dotted hold paths directly, for example,H.root_dog.value. This is equivalent to eitherself.hold["root_dog"].valueorself.hold[("root", "dog")].value.The expression
H.root_dog.value > 5compiles and evaluates directly as long asHis present in locals and references aHoldinstance. No substitution shorthand is required. Hierarchy in.holduses underscore-separated keys, so Box/Boxer/Actor names may not contain_(enforced by theRenamregex).
- property expr
Property getter for ._expr
- Returns:
evaluable boolean expression.
- Return type:
expr (str)
- property compiled
Property compiled
Returns:
compiled (bool): True means ._code holds compiled ._expr False means not yet compiled
- compile()
Compile evaluable boolean expression str ._expr into compiled code object ._code to be evaluated at run time. Because code objects are not pickleable the compilation must happen at prep (enter) time not init time.