如何将函数名称传递给函数然后调用它?是否可以不使用getattribute?
如何将类名传递给函数然后实例化该类?我知道我只是可以将类的实例直接传递给函数,但是在调用函数之后对类进行实例化非常重要.
def outer(f): # any name: function, class, any callable
return f() # class will be instantiated within the scope of the function
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
275 次 |
| 最近记录: |