Re: Trying to come to grips with static methods

2005-07-12 Thread Terry Reedy
| I've been doing a lot of reading about static methods in Python, and possibly getting over-confused by the minutia of the CPython implementation, as well as by the misnomer. Conceptually, a 'static method' is a function attribute of a class that is to be used as a function and not as a method

Re: Trying to come to grips with static methods

2005-07-12 Thread Cyril Bazin
Ok, sorry, you are right Robert. What about this one: class Parser(object):     def toParser(p):     if type(p) == str:     if len(p) == 1:     return lit(p)     return txt(p)     return p     toParser = staticmethod(toParser) This is meant to translate p to

Re: Trying to come to grips with static methods

2005-07-12 Thread Robert Kern
Cyril Bazin wrote: > (sorry, my fingers send the mail by there own ;-) > > Im my opinion, class method are used to store some functionalities > (function) related to a class in the scope of the class. > > For example, I often use static methods like that: > > class Point: > def __init__(sel

Re: Trying to come to grips with static methods

2005-07-12 Thread Cyril Bazin
(sorry, my fingers send the mail by there own ;-) Im my opinion, class method are used to store some functionalities (function) related to a class in the scope of the class. For example, I often use static methods like that: class Point:     def __init__(self, x, y):     self.x, self.y = x, y

Re: Trying to come to grips with static methods

2005-07-12 Thread Robert Kern
Steven D'Aprano wrote: > I've been doing a lot of reading about static methods in Python, and I'm > not exactly sure what they are useful for or why they were introduced. > > Here is a typical description of them, this one from Guido: > > "The new descriptor API makes it possible to add static me

Re: Trying to come to grips with static methods

2005-07-12 Thread Cyril Bazin
Im my opinion, class method are used to store some "functions" related to a class in the scope of the class. For example, I often use static methods like that: class Foo: On 7/12/05, Steven D'Aprano <[EMAIL PROTECTED]> wrote: I've been doing a lot of reading about static methods in Python, a

Trying to come to grips with static methods

2005-07-12 Thread Steven D'Aprano
I've been doing a lot of reading about static methods in Python, and I'm not exactly sure what they are useful for or why they were introduced. Here is a typical description of them, this one from Guido: "The new descriptor API makes it possible to add static methods and class methods. Static met