Re: Class Methods Vs Any Other Callable

2008-05-15 Thread [EMAIL PROTECTED]
On 15 mai, 17:53, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > > FWIW, I wonder why the BDFL choosed to implement __new__ as a > > staticmethod - there are probably some pretty good reasons, but not > > knowing them, it looks like __new__ would hav

Re: Class Methods Vs Any Other Callable

2008-05-15 Thread Arnaud Delobelle
Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > FWIW, I wonder why the BDFL choosed to implement __new__ as a > staticmethod - there are probably some pretty good reasons, but not > knowing them, it looks like __new__ would have been a perfect > candidate for a classmethod. > > So far, the only

Re: Class Methods Vs Any Other Callable

2008-05-15 Thread Bruno Desthuilliers
Arnaud Delobelle a écrit : [EMAIL PROTECTED] wrote: On 14 mai, 22:44, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: On 14 mai, 19:45, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: __new__ is a static method! __new__ is a special-cased staticmethod

Re: Class Methods Vs Any Other Callable

2008-05-15 Thread Arnaud Delobelle
[EMAIL PROTECTED] wrote: > On 14 mai, 22:44, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > > On 14 mai, 19:45, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > > >> __new__ is a static method! > > > > > __new__ is a special-cased staticmethod tha

Re: Class Methods Vs Any Other Callable

2008-05-15 Thread Bruno Desthuilliers
vbgunz a écrit : Instance methods make the most sense. A static method makes sense too *but* I can see how a class method not only does what a static method does but how a class method *also* gets the cls reference for free. I don't understand the last part - but I certainly agree on the "instan

Re: Class Methods Vs Any Other Callable

2008-05-15 Thread Bruno Desthuilliers
vbgunz a écrit : 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

Re: Class Methods Vs Any Other Callable

2008-05-15 Thread George Sakkis
On May 14, 4:38 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On 14 mai, 16:30, George Sakkis <[EMAIL PROTECTED]> wrote: > > > On May 14, 10:19 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > > > > An instance method works on the instance > > > > A Static method is basically a function

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread Arnaud Delobelle
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > On 14 mai, 22:44, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: >> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >> > On 14 mai, 19:45, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: >> >> __new__ is a static method! >> >> > __new__ is a special-cased

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread Ivan Illarionov
On Wed, 14 May 2008 09:21:10 -0700, vbgunz wrote: > [...] > when you see > one, what is the first thing that comes to mind? When you write one, > what was the first thing on your mind? Other than "similar to static- > methods", at what point will you be glad you used one? To sum it up, > what is t

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread [EMAIL PROTECTED]
On 14 mai, 22:44, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > On 14 mai, 19:45, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > >> __new__ is a static method! > > > __new__ is a special-cased staticmethod that 1/ must not be declared > > as such

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread Carl Banks
On May 14, 12:21 pm, vbgunz <[EMAIL PROTECTED]> wrote: > Other than the 2 reasons above (2 making more sense), what is a really > good reason to pull out the class method. In other words, when you see > one, what is the first thing that comes to mind? When you write one, > what was the first thing

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread Arnaud Delobelle
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > On 14 mai, 19:45, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: >> __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,

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread [EMAIL PROTECTED]
On 14 mai, 16:30, George Sakkis <[EMAIL PROTECTED]> wrote: > On May 14, 10:19 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> 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 anyt

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread [EMAIL PROTECTED]
On 14 mai, 19:45, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > George Sakkis <[EMAIL PROTECTED]> writes: > > On May 14, 10:19 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > >> > An instance method works on the instance > >> > A Static method is basically a function nested within a class obj

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread Arnaud Delobelle
George Sakkis <[EMAIL PROTECTED]> writes: > On May 14, 10:19 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> 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 meth

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread vbgunz
> > > Instance methods make the most sense. A static method makes sense too > > > *but* I can see how a class method not only does what a static method > > > does but how a class method *also* gets the cls reference for free. > > > I don't understand the last part - but I certainly agree on the "in

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread vbgunz
> > Instance methods make the most sense. A static method makes sense too > > *but* I can see how a class method not only does what a static method > > does but how a class method *also* gets the cls reference for free. > > I don't understand the last part - but I certainly agree on the "instance >

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread Diez B. Roggisch
> When I learned about static methods, I learned they're a way to > tightly couple some functionality with a class without tying the > functionality to any of the instances. I see them as nothing more than > a design decision. To me they make some sense. Which you can say exactly about classmethod

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread vbgunz
> > 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... > class Foo: > >   [EMAIL PROTECTED] >    def register(cls, listener): >        cls.LISTENERS.append(

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread George Sakkis
On May 14, 10:19 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> 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

Re: Class Methods Vs Any Other Callable

2008-05-14 Thread Diez B. Roggisch
> 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 refer

Class Methods Vs Any Other Callable

2008-05-14 Thread vbgunz
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