4
Bir 'sınıf yöntemi' ve bir metasınıf yöntemi arasındaki farklar nelerdir?
Python, @classmethoddekoratör kullanarak bir sınıf yöntemi oluşturabilir : >>> class C: ... @classmethod ... def f(cls): ... print(f'f called with cls={cls}') ... >>> C.f() f called with cls=<class '__main__.C'> Alternatif olarak, bir metasınıfta normal (örnek) bir yöntem kullanabilirim: >>> class M(type): ... def f(cls): ... print(f'f called with cls={cls}') ... …