Instance Analysis of inheritance chain of python Class
This article mainly explains the "python class inheritance chain example analysis", the article explains the content is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "python class inheritance chain example analysis"!
1. A subclass can inherit a parent class, and similarly, a parent class can inherit its own parent class, layer by layer.
Class A:def have (self): print ('I hava an apple') class B (A): pass class C (B): pass
2. If you want to determine whether a category is a subcategory of another class, you can use the built-in function issubclass ().
> issubclass (C, A) True > issubclass (B, A) True > issubclass (C, B) True Thank you for reading, the above is the "python class inheritance chain instance analysis" content, after the study of this article, I believe you have a deeper understanding of the python class inheritance chain example analysis of this problem, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!