更新时间:2022-04-28 23:57:19
正确。调用 double_inputs
不会执行任何代码。它只是返回一个 generator
对象。 def
语句被解析时发现的体内 yield
表达式的存在,更改 def
语句的语义以创建 generator
对象而不是 function
对象。
Correct. Calling double_inputs
never executes any of the code; it simply returns a generator
object. The presence of the yield
expression in the body, discovered when the def
statement is parsed, changes the semantics of the def
statement to create a generator
object rather than a function
object.