circuitpython/tests/basics/generator_name.py
Damien George e2e22e3d7e py/objgenerator: Implement __name__ with normal fun attr accessor code.
With the recent change b488a4a848, a
generating function now has the same layout in memory as a normal bytecode
function, and so can reuse the latter's attribute accessor code to
implement __name__.
2018-07-10 16:33:57 +10:00

17 lines
250 B
Python

# test __name__ on generator functions
def Fun():
yield
class A:
def Fun(self):
yield
try:
print(Fun.__name__)
print(A.Fun.__name__)
print(A().Fun.__name__)
except AttributeError:
print('SKIP')
raise SystemExit