Re: What is class method?

2008-08-27 Thread Bruno Desthuilliers
Medardo Rodriguez (Merchise Group) a écrit : On Tue, Aug 26, 2008 at 4:10 PM, Bruno Desthuilliers [EMAIL PROTECTED] wrote: In Python, there's *no* relationship between classmethods and metaclasses. In OOP the concept of meta-class has everything to do with class methods, regardless if is in

Re: What is class method?

2008-08-26 Thread Bruno Desthuilliers
MeTheGameMakingGuy a écrit : On Aug 24, 6:32 pm, Hussein B [EMAIL PROTECTED] wrote: Hi, I'm familiar with static method concept, but what is the class method? how it does differ from static method? when to use it? -- class M: def method(cls, x): pass method = classmethod(method) -- Thank

Re: What is class method?

2008-08-26 Thread Bruno Desthuilliers
Maric Michaud a écrit : (snip) It is a common advice that staticmethod should not exist in python, as they do nothing compared to module level functions, They do nothing more, but are accessible thru a class object instead of being accessible thru a module object. It sometimes happens to be

Re: What is class method?

2008-08-26 Thread Bruno Desthuilliers
Hussein B a écrit : Hi, I'm familiar with static method concept, Which is more often than not useless in Python - we have true functions and modules. but what is the class method? Short answer : It's a method that can be looked up upon both the class or an instance of it, and takes

Re: What is class method?

2008-08-26 Thread Medardo Rodriguez (Merchise Group)
On Tue, Aug 26, 2008 at 4:10 PM, Bruno Desthuilliers [EMAIL PROTECTED] wrote: In Python, there's *no* relationship between classmethods and metaclasses. In OOP the concept of meta-class has everything to do with class methods, regardless if is in Python, SmallTalk or CLOSS. classmethod decorator

Re: What is class method?

2008-08-26 Thread Raymond Hettinger
On Aug 24, 5:32 am, Hussein B [EMAIL PROTECTED] wrote: Hi, I'm familiar with static method concept, but what is the class method? how it does differ from static method? when to use it? I use them when I need alternative constructors for a class. class Angle(object): def __init__(self

Re: What is class method?

2008-08-26 Thread Matthew Fitzgibbons
Medardo Rodriguez (Merchise Group) wrote: On Tue, Aug 26, 2008 at 4:10 PM, Bruno Desthuilliers [EMAIL PROTECTED] wrote: In Python, there's *no* relationship between classmethods and metaclasses. In OOP the concept of meta-class has everything to do with class methods, regardless if is in

Re: What is class method?

2008-08-25 Thread Hrvoje Niksic
Steven D'Aprano [EMAIL PROTECTED] writes: On Sun, 24 Aug 2008 11:09:46 +0200, Hrvoje Niksic wrote: Use [classmethod] when your method needs to know what class it is called from. Ordinary methods know what class they are called from I guess I should have added and no more. :-) Why is

What is class method?

2008-08-24 Thread Hussein B
Hi, I'm familiar with static method concept, but what is the class method? how it does differ from static method? when to use it? -- class M: def method(cls, x): pass method = classmethod(method) -- Thank you for your time. -- http://mail.python.org/mailman/listinfo/python-list

Re: What is class method?

2008-08-24 Thread MeTheGameMakingGuy
On Aug 24, 6:32 pm, Hussein B [EMAIL PROTECTED] wrote: Hi, I'm familiar with static method concept, but what is the class method? how it does differ from static method? when to use it? -- class M:  def method(cls, x):     pass  method = classmethod(method) -- Thank you for your time

Re: What is class method?

2008-08-24 Thread Hrvoje Niksic
Hussein B [EMAIL PROTECTED] writes: Hi, I'm familiar with static method concept, but what is the class method? how it does differ from static method? when to use it? -- class M: def method(cls, x): pass method = classmethod(method) Use it when your method needs to know what class

Re: What is class method?

2008-08-24 Thread castironpi
On Aug 24, 3:35 am, MeTheGameMakingGuy [EMAIL PROTECTED] wrote: On Aug 24, 6:32 pm, Hussein B [EMAIL PROTECTED] wrote: Hi, I'm familiar with static method concept, but what is the class method? how it does differ from static method? when to use it? -- class M:  def method(cls, x

Re: What is class method?

2008-08-24 Thread Maric Michaud
Le Sunday 24 August 2008 10:32:34 Hussein B, vous avez écrit : Hi, I'm familiar with static method concept, but what is the class method? how it does differ from static method? when to use it? -- class M: def method(cls, x): pass method = classmethod(method) As it has been said

Re: What is class method?

2008-08-24 Thread Medardo Rodriguez (Merchise Group)
On Sun, Aug 24, 2008 at 4:32 AM, Hussein B [EMAIL PROTECTED] wrote: I'm familiar with static method concept, but what is the class method? how it does differ from static method? when to use it? Class Methods are related to the meta-class concept introduced since the first beginning of OOP

Re: What is class method?

2008-08-24 Thread Steven D'Aprano
On Sun, 24 Aug 2008 11:09:46 +0200, Hrvoje Niksic wrote: Hussein B [EMAIL PROTECTED] writes: Hi, I'm familiar with static method concept, but what is the class method? how it does differ from static method? when to use it? -- class M: def method(cls, x): pass method = classmethod