I have a function in a superclass that returns a new version of itself. I have a subclass of this super that inherits the particular function, but would rather it return a new version of the subclass. How do I code it so that when the function call is from the parent, it returns a version of the parent, but when it is called from the child, it returns a new version of the child?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
If
new
does not depend onself
, use a classmethod:Or, if
new
does depend onself
, usetype(self)
to determineself
's class: