diff options
| author | Martin Panter <vadmium+py@gmail.com> | 2016-09-17 07:54:55 (GMT) |
|---|---|---|
| committer | Martin Panter <vadmium+py@gmail.com> | 2016-09-17 07:54:55 (GMT) |
| commit | ca56dd4767617a2f5e946130de4beb06442a5cd5 (patch) | |
| tree | 8697f0e83d6b4f3758eaf4b89abc944b6e6db71f /Objects/funcobject.c | |
| parent | fd2f85d6e4e8abc9c943cf56cf45527d522c7882 (diff) | |
| download | cpython-ca56dd4767617a2f5e946130de4beb06442a5cd5.zip cpython-ca56dd4767617a2f5e946130de4beb06442a5cd5.tar.gz cpython-ca56dd4767617a2f5e946130de4beb06442a5cd5.tar.bz2 | |
Issue #28139: Fix messed up indentation
Also update the classmethod and staticmethod doc strings and comments to
match the RST documentation.
Diffstat (limited to 'Objects/funcobject.c')
| -rw-r--r-- | Objects/funcobject.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 0e76a44..c62de9c 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -590,8 +590,9 @@ PyTypeObject PyFunction_Type = { To declare a class method, use this idiom: class C: - def f(cls, arg1, arg2, ...): ... - f = classmethod(f) + @classmethod + def f(cls, arg1, arg2, ...): + ... It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()); the instance is ignored except for its class. @@ -676,8 +677,9 @@ just like an instance method receives the instance.\n\ To declare a class method, use this idiom:\n\ \n\ class C:\n\ - def f(cls, arg1, arg2, ...): ...\n\ - f = classmethod(f)\n\ + @classmethod\n\ + def f(cls, arg1, arg2, ...):\n\ + ...\n\ \n\ It can be called either on the class (e.g. C.f()) or on an instance\n\ (e.g. C().f()). The instance is ignored except for its class.\n\ @@ -748,8 +750,9 @@ PyClassMethod_New(PyObject *callable) To declare a static method, use this idiom: class C: - def f(arg1, arg2, ...): ... - f = staticmethod(f) + @staticmethod + def f(arg1, arg2, ...): + .... It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()); the instance is ignored except for its class. @@ -828,8 +831,9 @@ A static method does not receive an implicit first argument.\n\ To declare a static method, use this idiom:\n\ \n\ class C:\n\ - def f(arg1, arg2, ...): ...\n\ - f = staticmethod(f)\n\ + @staticmethod\n\ + def f(arg1, arg2, ...):\n\ + ...\n\ \n\ It can be called either on the class (e.g. C.f()) or on an instance\n\ (e.g. C().f()). The instance is ignored except for its class.\n\ |
