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
# A function or method which is defined using async def is called a coroutine function. Such a function, when called, returns a coroutine object. It may contain await expressions, as well as async with and async for statements. See also the Coroutine Objects section.
@@ -95,14 +101,15 @@ async def coro(x):
95
101
96
102
classA:
97
103
98
-
def__await__(self, x):
99
-
yieldx
104
+
def__await__(self):
105
+
# yield SOURCE -- see https://groups.google.com/g/dev-python/c/_lrrc-vp9TI?pli=1
SINK(asyncio.run(agen(SOURCE)))# fails with TypeError: 'A' object is not callable (possible query?)
112
+
SINK(asyncio.run(agen(SOURCE)))
106
113
107
114
# Asynchronous generator functions
108
115
# A function or method which is defined using async def and which uses the yield statement is called a asynchronous generator function. Such a function, when called, returns an asynchronous iterator object which can be used in an async for statement to execute the body of the function.
@@ -120,3 +127,169 @@ async def agen(x):
120
127
121
128
# Class Instances
122
129
# Instances of arbitrary classes can be made callable by defining a __call__() method in their class.
130
+
131
+
classCustomized:
132
+
133
+
a=NONSOURCE
134
+
b=NONSOURCE
135
+
136
+
def__new__(cls):
137
+
cls.a=SOURCE
138
+
returnsuper().__new__(cls)
139
+
140
+
def__init__(self):
141
+
self.b=SOURCE
142
+
143
+
customized=Customized()
144
+
SINK(Customized.a)
145
+
SINK_F(Customized.b)
146
+
SINK(customized.a)
147
+
SINK(customized.b)
148
+
149
+
# def __del__(self):
150
+
151
+
# If a class sets __iter__() to None, calling iter() on its instances will raise a TypeError (without falling back to __getitem__()).
152
+
153
+
# 3.3.1. Basic customization
154
+
# object.__new__(cls[, ...])
155
+
# object.__init__(self[, ...])
156
+
# object.__del__(self)
157
+
# object.__repr__(self)
158
+
# object.__str__(self)¶
159
+
# object.__bytes__(self)
160
+
# object.__format__(self, format_spec)
161
+
# object.__lt__(self, other)
162
+
# object.__le__(self, other)
163
+
# object.__eq__(self, other)
164
+
# object.__ne__(self, other)
165
+
# object.__gt__(self, other)
166
+
# object.__ge__(self, other)
167
+
# object.__hash__(self)
168
+
# object.__bool__(self)
169
+
# len
170
+
171
+
# 3.3.2. Customizing attribute access
172
+
# object.__getattr__(self, name)
173
+
# object.__getattribute__(self, name)
174
+
# object.__setattr__(self, name, value)
175
+
# object.__delattr__(self, name)
176
+
# object.__dir__(self)
177
+
178
+
# 3.3.2.2. Implementing Descriptors
179
+
# object.__get__(self, instance, owner=None)
180
+
# object.__set__(self, instance, value)
181
+
# object.__delete__(self, instance)
182
+
# object.__set_name__(self, owner, name)
183
+
184
+
# 3.3.2.4. __slots__
185
+
# object.__slots__
186
+
# __weakref__
187
+
# __dict__
188
+
189
+
# 3.3.3. Customizing class creation
190
+
# classmethod object.__init_subclass__(cls)
191
+
192
+
# 3.3.3.1. Metaclasses
193
+
# By default, classes are constructed using type(). The class body is executed in a new namespace and the class name is bound locally to the result of type(name, bases, namespace).
0 commit comments