I wrote a simple script:
class A:
def print1(self):
print(self)
@staticmethod
def print2(thing):
print(thing)
A.print1('123')
A.print2('123')
print(A.print1)
print(A.print2)
And the output is:
123
123
<function A.print1 at 0x7f2f4a1778c8>
<function A.print2 at 0x7f2f4a17b510>
First YES or NO: Seems for now A.print1 and A.print2 do all same on functional, right?
As code from Python on Github:
/* Bind a function to an object */
static PyObject *
func_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
if (obj == Py_None || obj == NULL) {
Py_INCREF(func);
return func;
}
return PyMethod_New(func, obj);
}
And Python version StaticMethod from Descriptor HowTo Guide
class StaticMethod(object):
"Emulate PyStaticMethod_Type() in Objects/funcobject.c"
def __init__(self, f):
self.f = f
def __get__(self, obj, objtype=None):
return self.f
Second YES or NO: Does A.print1 and A.print2 all just get a function very same like print_pure which defined below, right?
def print_pure(thing):
print(thing)