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.

I agree with your sentiments, although I'm not sure I would pick metaclasses over class methods... or over anything at all, for that matter. :-)

They have the following issues:
1. You mix instance-level and class-level functionality in one place making your code a mess.
2. They are slower than metaclass methods or plain functions.

The way I see it, a class method is really just sugar for a function operating on the class, living in the class namespace. As such, they are basically redundant, and as you point out, they can always be replaced by a function outside the class (and in fact, this was what people did before they came along in 2.2). Personally, I don't use them... but some people like them. Different strokes, and all that...

--Hans
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to