factored out the python interface from the C++ interface