You have a couple different ways to do this.
-
You can pickle an object and store it.
-
You can store the source code and use
eval
orexec
to execute it. -
You can create your own serialized data format and dynamically build the filters from it in your code.
Keep in mind that a function call in Python like:
some_function(parm_1=value_1, parm_2=value_2)
is functionally identical to:
parm_dict = {'parm_1': value_1, 'parm_2': value_2}
some_function(**parm_dict)
which means you can dynamically create a filter from your data.
We actually use the last two techniques in a couple projects.