Factory Pattern in Python