callable
Topic source两个是不一样的。 callable(Student)是对类,callable(Student())是对Student类的对象
Note that classes are callable (calling a class returns a new instance); class instances are callable if they have a call() method.
在此插入代码
callable(Student())
程序运行的时候是会报错
Traceback (most recent call last): File "oopad.py", line 199, in <module> print(callable(Student())) TypeError: _init() missing 1 required positional argument: 'name'
callable(Student)
运行结果才为True
- 1
冬凉默殇
callable(Student())应为callable(Student)