metaclass
Topic source最后关于new调用后是否会调用init的问题,建议大家看下官方文档: Typical implementations create a new instance of the class by invoking the superclass’s new() method using super().new(cls[, ...]) with appropriate arguments and then modifying the newly-created instance as necessary before returning it.
If new() returns an instance of cls, then the new instance’s init() method will be invoked like init(self[, ...]), where self is the new instance and the remaining arguments are the same as were passed to new().
If new() does not return an instance of cls, then the new instance’s init() method will not be invoked.
- 1
Mr_RightMen