Pythonで記述子がどのように機能するかを理解しようとしています。全体像は把握できましたが、@staticmethod デコレータを理解するのに問題があります。
私が具体的に参照しているコードは、対応する python ドキュメントからのものです: https://docs.python.org/3/howto/descriptor.html
class Function(object):
. . .
def __get__(self, obj, objtype=None):
"Simulate func_descr_get() in Objects/funcobject.c"
if obj is None:
return self
return types.MethodType(self, obj)
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
私の質問は次のとおりです。self.f
最後の行でアクセスされたときに、記述子自体として認識されずf
(すべての関数が非データ記述子であるため)、StaticMethod オブジェクトである自己にバインドされますか?