"spir" <[EMAIL PROTECTED]> wrote

I have not yet found any use for this feature.

While there are subtle differences I believe the biggest
reason for both being present is history. static methods
were there first then class methods were added soon after
and are slightly more flexible. But statics were kept
because people were already using them.

Personally I usually use classmethod nowadays.

Also, I do not really understand the difference with @classmethod, from the programmer's points of view (even if I get the difference on the python side). As I see it, a classmethod is a very ordinary method, except its 'owner' is a type.

Which makes it very different to an instance method. instance
methods act on instances. class methods act on the entire
class - ie they can affect all of the instances or none.

You don't need to use class methods(or statics) very often
but when you do they are invaluable. The example of a factory
method, or a selection method (from a database say), or a cache
of instances. All of these can be done elegantly with class methods.

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to