See this add-on on the kodi.tv showcase
A library for easily adding evaluatable expressions into python projects