Class Methods Vs Any Other Callable

vbgunz vbgunz at gmail.com
Wed May 14 10:04:50 EDT 2008


I remember learning closures in Python and thought it was the dumbest
idea ever. Why use a closure when Python is fully object oriented? I
didn't grasp the power/reason for them until I started learning
JavaScript and then BAM, I understood them.

Just a little while ago, I had a fear of decorators because I really
couldn't find a definitive source to learn them (how to with with @).
How important are they? They must be important otherwise why have'em
in the language? I had to learn'em and then suddenly, BAM. I
understand them.

My main issue with closures and decorators was hidden in the fact of
how *dead simple* they were. All I needed were reasons to use them
over doing it X style. So what is my point? How dead simple are class
methods? I must be missing there point so I am convinced they must be
dead simple.

classes, functions, instance and static methods are easy. So easy in
fact, I could shoot myself in the foots without looking (preferably
without aiming). So, why am I stuck on the *idea* of a class method?

An instance method works on the instance
A Static method is basically a function nested within a class object
A class method is overkill?

I can call a static or class method through either the class OR any
instance of it. I've never designed a method that took advantage of
the class name except in cases where I needed to extend a super class
*but* even in this case, I didn't use the enclosing class name...

Whats the deal with class methods, why use them over anything else?
What does a class method accomplish in at least one line shorter than
anything else? Does it help reduce duplication or typing? I am at a
lost for words that can shed at least *one* good reason to use them.

What is the one greatest reason to use them? A little syntax and
explanation can go a long long way. I am failing to understand them so
any help is really appreciated here!



More information about the Python-list mailing list