You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# These are the types to which the function call operation (see section Calls) can be applied:
32
55
@@ -41,17 +64,19 @@ def f(a, b):
41
64
# An instance method object combines a class, a class instance and any callable object (normally a user-defined function).
42
65
classC(object):
43
66
44
-
defmethod(self, x, cls):
45
-
assertclsisself.__class__
46
-
returnx
67
+
defmethod(self, x, y):
68
+
SINK1(x)
69
+
SINK2(y)
47
70
48
71
@classmethod
49
-
defclassmethod(cls, x):
50
-
returnx
72
+
defclassmethod(cls, x, y):
73
+
SINK1(x)
74
+
SINK2(y)
51
75
52
76
@staticmethod
53
-
defstaticmethod(x):
54
-
returnx
77
+
defstaticmethod(x, y):
78
+
SINK1(x)
79
+
SINK2(y)
55
80
56
81
defgen(self, x, count):
57
82
n=count
@@ -64,30 +89,39 @@ async def coro(self, x):
64
89
65
90
c=C()
66
91
67
-
# When an instance method object is created by retrieving a user-defined function object from a class via one of its instances, its __self__ attribute is the instance, and the method object is said to be bound. The new method’s __func__ attribute is the original function object.
68
-
func_obj=c.method.__func__
92
+
@expects(6)
93
+
deftest_method_call():
94
+
# When an instance method object is created by retrieving a user-defined function object from a class via one of its instances, its __self__ attribute is the instance, and the method object is said to be bound. The new method’s __func__ attribute is the original function object.
95
+
func_obj=c.method.__func__
96
+
97
+
# When an instance method object is called, the underlying function (__func__) is called, inserting the class instance (__self__) in front of the argument list. For instance, when C is a class which contains a definition for a function f(), and x is an instance of C, calling x.f(1) is equivalent to calling C.f(x, 1).
# When an instance method object is called, the underlying function (__func__) is called, inserting the class instance (__self__) in front of the argument list. For instance, when C is a class which contains a definition for a function f(), and x is an instance of C, calling x.f(1) is equivalent to calling C.f(x, 1).
# When an instance method object is created by retrieving a class method object from a class or instance, its __self__ attribute is the class itself, and its __func__ attribute is the function object underlying the class method.
106
+
c_func_obj=C.classmethod.__func__
75
107
76
-
# When an instance method object is created by retrieving a class method object from a class or instance, its __self__ attribute is the class itself, and its __func__ attribute is the function object underlying the class method.
77
-
c_func_obj=C.classmethod.__func__
108
+
# When an instance method object is derived from a class method object, the “class instance” stored in __self__ will actually be the class itself, so that calling either x.f(1) or C.f(1) is equivalent to calling f(C,1) where f is the underlying function.
# When an instance method object is derived from a class method object, the “class instance” stored in __self__ will actually be the class itself, so that calling either x.f(1) or C.f(1) is equivalent to calling f(C,1) where f is the underlying function.
# When an instance method object is created by retrieving a class method object from a class or instance, its __self__ attribute is the class itself, and its __func__ attribute is the function object underlying the class method.
85
-
s_func_obj=C.staticmethod.__func__
114
+
@expects(5)
115
+
deftest_staticmethod_call():
116
+
# staticmethods does not have a __func__ attribute
117
+
try:
118
+
C.staticmethod.__func__
119
+
exceptAttributeError:
120
+
print("OK")
86
121
87
-
# When an instance method object is derived from a class method object, the “class instance” stored in __self__ will actually be the class itself, so that calling either x.f(1) or C.f(1) is equivalent to calling f(C,1) where f is the underlying function.
# When an instance method object is derived from a class method object, the “class instance” stored in __self__ will actually be the class itself, so that calling either x.f(1) or C.f(1) is equivalent to calling f(C,1) where f is the underlying function.
0 commit comments