在运行时创建 class 是什么意思?还有 python 中的运行时间是什么意思?
What does it mean to say creating class at runtime ? and also what does runtime mean in python?
我正在浏览文档,关于 类 的 python 教程,我发现这一行非常混乱。 Here
As is true for modules, classes partake of the dynamic nature of Python: they are created at runtime, and can be modified further after creation.
'class partake of the dynamic nature of Python' 是什么意思:它们是在运行时创建的?为什么模块是这样的?
到目前为止,我所了解到的 类 是它们被创建为,
class Democlass():
pass
我是在运行时创建它吗?谷歌搜索后我发现 Here 类 可以通过下面的代码在运行时创建,但我不明白为什么它表示为运行时创建而上面的代码不是,两者之间有什么区别两个?
cls = type('A', (object,), {'__doc__': 'class created by type'})
print(cls)
print(cls.__doc__)
'dynamic nature of python' 和 'runtime' 之间的 link 是什么?
如果有人提供帮助,我将不胜感激。
提前致谢。
表示在运行程序时创建class,在运行程序
时可以更改
我正在浏览文档,关于 类 的 python 教程,我发现这一行非常混乱。 Here
As is true for modules, classes partake of the dynamic nature of Python: they are created at runtime, and can be modified further after creation.
'class partake of the dynamic nature of Python' 是什么意思:它们是在运行时创建的?为什么模块是这样的? 到目前为止,我所了解到的 类 是它们被创建为,
class Democlass():
pass
我是在运行时创建它吗?谷歌搜索后我发现 Here 类 可以通过下面的代码在运行时创建,但我不明白为什么它表示为运行时创建而上面的代码不是,两者之间有什么区别两个?
cls = type('A', (object,), {'__doc__': 'class created by type'})
print(cls)
print(cls.__doc__)
'dynamic nature of python' 和 'runtime' 之间的 link 是什么? 如果有人提供帮助,我将不胜感激。 提前致谢。
表示在运行程序时创建class,在运行程序
时可以更改