What are Class methods in Python for?

Posted by Dave Webb on Stack Overflow See other posts from Stack Overflow or by Dave Webb
Published on 2008-09-01T18:16:41Z Indexed on 2010/05/11 1:54 UTC
Read the original article Hit count: 234

Filed under:

I'm teaching myself Python and my most recent lesson was that Python is not Java, and so I've just spent a while turning all my Class methods into functions.

I now realise that I don't need to use Class methods for what I would done with static methods in Java, but now I'm not sure when I would use them. All the advice I can find about Python Class methods is along the lines of newbies like me should steer clear of them, and the standard documentation is at its most opaque when discussing them.

Does anyone have a good example of using a Class method in Python or at least can someone tell me when Class methods can be sensibly used?

© Stack Overflow or respective owner

Related posts about python