Terry Reedy a écrit :
Kurt Symanzik wrote:
But you might consider decorating the method as a static method
instead since in your example you are not using the parameter at all.
A static method would not require a parameter.
@staticmethod
def print_hello():
print hello
Functions
On May 8, 7:52 pm, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
On Thu, 07 May 2009 04:27:15 -0700, Aaron Brady wrote:
Can be, but if there's reason enough to keep it with a class, there's
no reason not to.
That's a bit of hyperbole; the usual reasons such as code bloat,
On Thu, 07 May 2009 04:27:15 -0700, Aaron Brady wrote:
Can be, but if there's reason enough to keep it with a class, there's
no reason not to.
That's a bit of hyperbole; the usual reasons such as code bloat,
namespace bloat, maintainability etc. all weigh against it. It's just
that the
On Thu, 07 May 2009 00:39:28 -0400, Terry Reedy wrote:
Functions that refer to neither the class nor an instance thereof can
usually be moved outside the class altogether. Python is not Java. I
believe staticmethod() was mainly added because it is needed for
.__new__(), at least in some
On May 7, 1:29 am, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
On Thu, 07 May 2009 00:39:28 -0400, Terry Reedy wrote:
Functions that refer to neither the class nor an instance thereof can
usually be moved outside the class altogether. Python is not Java. I
believe
Hi, ALL:
I have a sample code as bellow:
#!/usr/bin/env python
class Hello:
def __init__(self):
print Hello __init__
@classmethod
def print_hello(self):
print hello
Hello.print_hello()
If I move self parameter of print_hello away, this code fragment won't
work.
I
On Wed, May 6, 2009 at 7:49 PM, Jianchun Zhou jianchun.z...@gmail.com wrote:
Hi, ALL:
I have a sample code as bellow:
#!/usr/bin/env python
class Hello:
def __init__(self):
print Hello __init__
@classmethod
def print_hello(self):
print hello
Jianchun Zhou jianchun.z...@gmail.com wrote on 2009-05-07 10:49:33 AM
+0800
I have a sample code as bellow:
#!/usr/bin/env python
class Hello:
def __init__(self):
print Hello __init__
@classmethod
def print_hello(self):
print hello
Hello.print_hello()
If I move
Kurt Symanzik wrote:
But you might consider decorating the method as a static method instead
since in your example you are not using the parameter at all. A static
method would not require a parameter.
@staticmethod
def print_hello():
print hello
Functions that refer to neither the