How to do generalize Python+CPP classes...