Executing python expression from module

This post may be helpful. You can ignore the alarm-specific parts, but basically what you need is an ExpressionParseContext. Searching for that term yields a couple other results too.