I am reading Effective Python by Slatkin. In item 24, he talks about achieving polymorphism in python by using classmethod
functions that play the role of constructors.
However, it is not clear to me why this is necessary. Why can we not achieve the same goal by simply using __init__
and overriding it in every derived class, the same way we're overriding the classmethod
?
In his case, he has only one constructor per class, so why not use regular init for that purpose rather than classmethod?
You can see what's item 24 here, unfortunately details are missing: http://ptgmedia.pearsoncmg.com/images/9780134034287/samplepages/9780134034287.pdf
More details here: http://qiita.com/giwa/items/fd563a93825714cffd70