Re: [Tutor] classmethod, staticmethod functions (decorator related)

2010-09-13 Thread Alan Gauld
"Huy Ton That" wrote I was taking a look at the module decimal.py as you cited, and it makes sense now. Looks very useful to make tools without having to instantiate anything. Thats not a good way to think of them. Doing things without instantiating is usually better done by a function.

Re: [Tutor] classmethod, staticmethod functions (decorator related)

2010-09-13 Thread Huy Ton That
Thank you all, I was taking a look at the module decimal.py as you cited, and it makes sense now. Looks very useful to make tools without having to instantiate anything. On Mon, Sep 13, 2010 at 7:05 AM, Steven D'Aprano wrote: > On Mon, 13 Sep 2010 12:29:07 pm Huy Ton That wrote: > > Hm, thanks g

Re: [Tutor] classmethod, staticmethod functions (decorator related)

2010-09-13 Thread Steven D'Aprano
On Mon, 13 Sep 2010 12:29:07 pm Huy Ton That wrote: > Hm, thanks guys; I just had to verify I was thinking sanely about it. > I am going to pick up classmethods next. Do any of you have common > design patterns for the usage. They are just items I haven't > integrated in my coding, and I want to be

Re: [Tutor] classmethod, staticmethod functions (decorator related)

2010-09-12 Thread Huy Ton That
Hm, thanks guys; I just had to verify I was thinking sanely about it. I am going to pick up classmethods next. Do any of you have common design patterns for the usage. They are just items I haven't integrated in my coding, and I want to be certain I'm off on the right foot (: On Sun, Sep 12, 2010

Re: [Tutor] classmethod, staticmethod functions (decorator related)

2010-09-12 Thread Alan Gauld
"Steven D'Aprano" wrote A little more information... static methods are quite common[1] in Java and C++, where people feel the need (or in the case of Java, are forced by the language) to make every function a method. static methods in C++ are normally reserved for use as class methods (alt

Re: [Tutor] classmethod, staticmethod functions (decorator related)

2010-09-12 Thread Steven D'Aprano
On Mon, 13 Sep 2010 09:13:25 am Steven D'Aprano wrote: > On Mon, 13 Sep 2010 06:05:23 am Alan Gauld wrote: > > I think static methjods are largely a mistake of history. ISTR They > > were > > introduced into python before class methods (not by much - one > > release?) > > No, they were introduced a

Re: [Tutor] classmethod, staticmethod functions (decorator related)

2010-09-12 Thread Steven D'Aprano
On Mon, 13 Sep 2010 06:05:23 am Alan Gauld wrote: > I think static methjods are largely a mistake of history. ISTR They > were > introduced into python before class methods (not by much - one > release?) No, they were introduced at the same time. But it turned out that the use cases Guido van Ro

Re: [Tutor] classmethod, staticmethod functions (decorator related)

2010-09-12 Thread Alan Gauld
"Huy Ton That" wrote class WhatFor(object): def it(cls): print 'work with %s' % cls it = classmethod(it) def uncommon(): print 'I could be a global function' uncommon = staticmethod(uncommon) But I can't seem to understand the above. Under what circumstance would st

Re: [Tutor] classmethod, staticmethod functions (decorator related)

2010-09-11 Thread Steven D'Aprano
On Sat, 11 Sep 2010 12:35:48 am Huy Ton That wrote: > I am reading the decorator section within Expert Python Programming > and I am very confused in the first example, of a method that was > done before decorators. It reads: > > class WhatFor(object): > def it(cls): > print 'work with

[Tutor] classmethod, staticmethod functions (decorator related)

2010-09-10 Thread Huy Ton That
I am reading the decorator section within Expert Python Programming and I am very confused in the first example, of a method that was done before decorators. It reads: class WhatFor(object): def it(cls): print 'work with %s' % cls it = classmethod(it) def uncommon(): pr