On Sat, 17 May 2008 04:01:50 +0000, Ivan Illarionov wrote: > After re-reading "Python is not Java" I finally came to conclusion that > classmethods in Python are a very Bad Thing. > > I can't see any use-case of them that couldn't be re-written more clearly > with methods of metaclass or plain functions.
*The* use case IMHO are alternative constructors. They belong to the class, so functions are not as clear and it's possible to have more than one class in a module with class methods of the same name, e.g. `A.from_string()` and `B.from_string()` vs. `create_a_from_string()` and `create_b_from_string()`. And I don't see how functions can be inherited by sub classes like class methods can. Metaclasses are more clear than class methods? You must be joking!? > They have the following issues: > 1. You mix instance-level and class-level functionality in one place > making your code a mess. Writing meta classes just for alternative constructors seems to be more of a mess to me. Too much magic for such a simple case for my taste. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list