t553.trans 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. Module(body=[ImportFrom(module='time',
  2. names=[alias(name='sleep',
  3. asname=None)],
  4. level=0),
  5. ClassDef(name='GeneratorClass',
  6. bases=[],
  7. body=[Assign(targets=[Name(id='test',
  8. ctx=Store())],
  9. value=Str(s='hi')),
  10. FunctionDef(name='__init__',
  11. args=arguments(args=[Name(id='self',
  12. ctx=Param())],
  13. vararg=None,
  14. kwarg=None,
  15. defaults=[]),
  16. body=[Pass()],
  17. decorator_list=[]),
  18. FunctionDef(name='generator',
  19. args=arguments(args=[Name(id='self',
  20. ctx=Param())],
  21. vararg=None,
  22. kwarg=None,
  23. defaults=[]),
  24. body=[Print(dest=None,
  25. values=[Attribute(value=Name(id='self',
  26. ctx=Load()),
  27. attr='test',
  28. ctx=Load())],
  29. nl=True),
  30. For(target=Name(id='i',
  31. ctx=Store()),
  32. iter=Call(func=Name(id='range',
  33. ctx=Load()),
  34. args=[Num(n=10)],
  35. keywords=[],
  36. starargs=None,
  37. kwargs=None),
  38. body=[Expr(value=Yield(value=Name(id='i',
  39. ctx=Load())))],
  40. orelse=[])],
  41. decorator_list=[]),
  42. FunctionDef(name='sleeping_generator',
  43. args=arguments(args=[Name(id='self',
  44. ctx=Param())],
  45. vararg=None,
  46. kwarg=None,
  47. defaults=[]),
  48. body=[Print(dest=None,
  49. values=[Attribute(value=Name(id='self',
  50. ctx=Load()),
  51. attr='test',
  52. ctx=Load())],
  53. nl=True),
  54. For(target=Name(id='i',
  55. ctx=Store()),
  56. iter=Call(func=Name(id='range',
  57. ctx=Load()),
  58. args=[Num(n=10)],
  59. keywords=[],
  60. starargs=None,
  61. kwargs=None),
  62. body=[Expr(value=Call(func=Name(id='sleep',
  63. ctx=Load()),
  64. args=[Num(n=0.01)],
  65. keywords=[],
  66. starargs=None,
  67. kwargs=None)),
  68. Expr(value=Yield(value=Name(id='i',
  69. ctx=Load())))],
  70. orelse=[])],
  71. decorator_list=[])],
  72. decorator_list=[]),
  73. Assign(targets=[Name(id='gen',
  74. ctx=Store())],
  75. value=Call(func=Name(id='GeneratorClass',
  76. ctx=Load()),
  77. args=[],
  78. keywords=[],
  79. starargs=None,
  80. kwargs=None)),
  81. For(target=Name(id='g',
  82. ctx=Store()),
  83. iter=Call(func=Attribute(value=Name(id='gen',
  84. ctx=Load()),
  85. attr='generator',
  86. ctx=Load()),
  87. args=[],
  88. keywords=[],
  89. starargs=None,
  90. kwargs=None),
  91. body=[Print(dest=None,
  92. values=[Name(id='g',
  93. ctx=Load())],
  94. nl=True)],
  95. orelse=[]),
  96. For(target=Name(id='g',
  97. ctx=Store()),
  98. iter=Call(func=Attribute(value=Name(id='gen',
  99. ctx=Load()),
  100. attr='sleeping_generator',
  101. ctx=Load()),
  102. args=[],
  103. keywords=[],
  104. starargs=None,
  105. kwargs=None),
  106. body=[Print(dest=None,
  107. values=[Name(id='g',
  108. ctx=Load())],
  109. nl=True)],
  110. orelse=[]),
  111. Print(dest=None,
  112. values=[Call(func=Name(id='list',
  113. ctx=Load()),
  114. args=[Call(func=Attribute(value=Name(id='gen',
  115. ctx=Load()),
  116. attr='generator',
  117. ctx=Load()),
  118. args=[],
  119. keywords=[],
  120. starargs=None,
  121. kwargs=None)],
  122. keywords=[],
  123. starargs=None,
  124. kwargs=None)],
  125. nl=True),
  126. Print(dest=None,
  127. values=[Call(func=Name(id='list',
  128. ctx=Load()),
  129. args=[Call(func=Attribute(value=Name(id='gen',
  130. ctx=Load()),
  131. attr='sleeping_generator',
  132. ctx=Load()),
  133. args=[],
  134. keywords=[],
  135. starargs=None,
  136. kwargs=None)],
  137. keywords=[],
  138. starargs=None,
  139. kwargs=None)],
  140. nl=True),
  141. Print(dest=None,
  142. values=[ListComp(elt=BinOp(left=Name(id='x',
  143. ctx=Load()),
  144. op=Mult(),
  145. right=Num(n=2)),
  146. generators=[comprehension(target=Name(id='x',
  147. ctx=Store()),
  148. iter=Call(func=Attribute(value=Name(id='gen',
  149. ctx=Load()),
  150. attr='generator',
  151. ctx=Load()),
  152. args=[],
  153. keywords=[],
  154. starargs=None,
  155. kwargs=None),
  156. ifs=[])])],
  157. nl=True),
  158. Print(dest=None,
  159. values=[ListComp(elt=BinOp(left=Name(id='x',
  160. ctx=Load()),
  161. op=Mult(),
  162. right=Num(n=2)),
  163. generators=[comprehension(target=Name(id='x',
  164. ctx=Store()),
  165. iter=Call(func=Attribute(value=Name(id='gen',
  166. ctx=Load()),
  167. attr='sleeping_generator',
  168. ctx=Load()),
  169. args=[],
  170. keywords=[],
  171. starargs=None,
  172. kwargs=None),
  173. ifs=[])])],
  174. nl=True)])