Class Methods Vs Any Other Callable

bruno.desthuilliers at gmail.com bruno.desthuilliers at gmail.com
Wed May 14 16:35:19 EDT 2008


On 14 mai, 19:45, Arnaud Delobelle <arno... at googlemail.com> wrote:
> George Sakkis <george.sak... at gmail.com> writes:
> > On May 14, 10:19 am, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
>
> >> > An instance method works on the instance
> >> > A Static method is basically a function nested within a class object
> >> > A class method is overkill?
>
> >> If anything, a static method is overkill. See it this way: *if* you for some
> >> reason put a method into an enclosing context - isn't it worth having a
> >> reference to that?
>
> > My feeling exactly; these days I almost always use class methods
> > instead of static. I vaguely remember seeing somewhere an example
> > where a static method was the only (elegant) solution; neither a class
> > method nor a plain function would do. I'll post it if I find it unless
> > someone beats me to it.
>
> > George
>
> __new__ is a static method!

__new__ is a special-cased staticmethod that  1/ must not be declared
as such and 2/ takes the class object as first args. As far as I'm
concerned, it's semantically a classmethod.



More information about the Python-list mailing list