Model.macros#

property Model.macros#

Return a mapping of macros.

Returns a dictionary-like view of all macros defined in the model. Macros are Python functions that can be saved within the model and executed to manipulate or query the model.

Example

>>> import modelx as mx
>>> m = mx.new_model('MyModel')
>>> @mx.defmacro
... def get_name():
...     return mx_model._name
>>> m.macros
{'get_name': <Macro MyModel.get_name>}
>>> m.get_name()
'MyModel'

See also

Added in version 0.30.0.