Add example of factory method pattern in python
Add c++ factory example and make python version more consistent with it