How to get the list of variables used in a Rule #108
-
I have created a Rule object like below rule = rule_engine.Rule("Name == 'John' and Type== 'Auto'") How can I get the list of variables used in my rule, ie. I want to get "Name" and "Type". In my use case, the rules are very dynamic and are red from a file, so they might contain different variables. I need to dynaically be able to understand what variables are used in each rule. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
There's a https://zerosteiner.github.io/rule-engine/rule_engine/engine.html#rule_engine.engine.Context.symbols Should be something like |
Beta Was this translation helpful? Give feedback.
There's a
symbols
attribute on the context object. Assuming the context isn't shared across multiple rules, you can access it to see the symbols.https://zerosteiner.github.io/rule-engine/rule_engine/engine.html#rule_engine.engine.Context.symbols
Should be something like
rule.context.symbols
.