| 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
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
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
(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
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
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
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