Steven Bethard wrote:
> (For anyone else out there reading who doesn't already know this,
> Steven D'Aprano's comments are easily explained by noting that the
> __get__ method of staticmethod objects returns functions, and classes
> always call the __get__ methods of descriptors when those desc
On Wed, 01 Mar 2006 08:32:20 -0700, Steven Bethard wrote:
> (For anyone else out there reading who doesn't already know this, Steven
> D'Aprano's comments are easily explained by noting that the __get__
> method of staticmethod objects returns functions, and classes always
> call the __get__ me
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> >>> class Parrot:
> ... def speak():
> ... return "dead parrot"
> ... speak = staticmethod(speak)
> ... def playdead():
> ... return "still dead"
> ...
> >>> type(Parrot.speak)
>
>
Steven Bethard wrote:
> ...
> Yes, you have to explain descriptors, but at the point that you start
> trying to do funny things with staticmethods and classmethods, I think
> you need to start learning about them anyway.)
That's all good points, but IMHO, descriptors are a much more advanced
Py
Steven D'Aprano wrote:
> So, based on this evidence, staticmethod() inside a class definition
> converts instance methods to functions. Outside a class definition,
> staticmethod() does one of two things: it either converts an instance
> method to a static method, or if the output is assigned to
Nicolas Fleury wrote:
> Hi everyone,
> I was wondering if it would make sense to make staticmethod objects
> callable, so that the following code would work:
This is one of the more unintuitive areas of Python,
with side effects and different behaviour depending on
whether code
You have a text-database, each record has some "header info" and some
data (text-blob). e.g.
name = "Tom"
phone = "312-996-"
I last met tom in 1998. He was still single then.
blah
blah
name = "John"
birthday = "1976-Mar-12"
I need to ask him his email when I see him ne
Steven Bethard wrote:
> Nicolas Fleury wrote:
>
>> I was wondering if it would make sense to make staticmethod objects
>> callable, so that the following code would work:
>>
>> class A:
>> @staticmethod
>> def foo(): pass
>> bar =
Felipe Almeida Lessa wrote:
> Em Ter, 2006-02-28 às 15:17 -0500, Nicolas Fleury escreveu:
>
>>class A:
>> @staticmethod
>> def foo(): pass
>> bar = foo()
>
>
> # Why not:
>
> def foo(): pass
>
> class A:
> bar = foo()
> foo = staticmethod(foo)
>
Well, you could even d
Em Ter, 2006-02-28 às 15:17 -0500, Nicolas Fleury escreveu:
> class A:
> @staticmethod
> def foo(): pass
> bar = foo()
# Why not:
def foo(): pass
class A:
bar = foo()
foo = staticmethod(foo)
--
"Quem excele em empregar a força militar subjulga os exércitos dos
ou
Nicolas Fleury wrote:
> I was wondering if it would make sense to make staticmethod objects
> callable, so that the following code would work:
>
> class A:
> @staticmethod
> def foo(): pass
> bar = foo()
Do you have a real-world use case? I pretty much nev
Hi everyone,
I was wondering if it would make sense to make staticmethod objects
callable, so that the following code would work:
class A:
@staticmethod
def foo(): pass
bar = foo()
I understand staticmethod objects don't need to implement __call__ for
their other use cases
12 matches
Mail list logo