Python factory method