【发布时间】:2017-04-16 20:41:28
【问题描述】:
在定义类 Foo 或函数 Bar 时,我得到:
>>> import MethodType
>>> type(Foo)
classobj
>>> type(Bar)
function
>>> type(MethodType)
type
我的问题是,我如何自己定义一个类/函数,使其类型为“类型”?
非常感谢。
【问题讨论】:
在定义类 Foo 或函数 Bar 时,我得到:
>>> import MethodType
>>> type(Foo)
classobj
>>> type(Bar)
function
>>> type(MethodType)
type
我的问题是,我如何自己定义一个类/函数,使其类型为“类型”?
非常感谢。
【问题讨论】:
在定义 Foo 类时,您没有从 object 继承:
class Foo(object):
...
【讨论】: