Home > other >  abnormal
abnormal

Time:09-19

Please inform
Class ab inherit a BaseException classes and a aa class aa class some methods, topic is treated with ab aa class possible exception,
As with ab to rewrite the inside of the aa method and add the try the except can be solved, but why must inherit BaseException?? ? Small white please inform,

CodePudding user response:

As you say, it is not inherit BaseException, unless the ab should also be used to as a exception

CodePudding user response:

reference 1st floor nieoding response:
according to what you say, is not inherited BaseException unless ab is used when the exception with

Despite the title, a class inherits BaseException how do?

CodePudding user response:

refer to the second floor qq_45883336 response:
apart from the title, a class inherits BaseException how do?


It's a long story! I try to say simple!!!!
First of all, inheritance is one of the three features of object-oriented languages!
The benefits of inheritance is to increase the reusability of the code, and show that the hierarchical relationship between class!
Take a parent-child relationship, for instance, like father son long, everything can be thought of as genetic inheritance,
Some get help son. Son make uncertain, he can easily find father,,,
If there is an orphan, he helpless, always have to depend on oneself!

It's like you write a class, if what classes are not inherited, any method to write yourself!
And inherited a class, even if the class definition is empty, but it is the parent of the method can be used as!

CodePudding user response:

I understand the concept of inheritance, is the inheritance BaseException don't know what role, BaseException seems to be the father of all exceptions classes,

CodePudding user response:

reference paullbm reply: 3/f
Quote: refer to the second floor qq_45883336 response:

Despite the title, a class inherits BaseException how do?


It's a long story! I try to say simple!!!!
First of all, inheritance is one of the three features of object-oriented languages!
The benefits of inheritance is to increase the reusability of the code, and show that the hierarchical relationship between class!
Take a parent-child relationship, for instance, like father son long, everything can be thought of as genetic inheritance,
Some get help son. Son make uncertain, he can easily find father,,,
If there is an orphan, he helpless, always have to depend on oneself!

It's like you write a class, if what class are not inherited, any method to write yourself!
And inherited a class, then the parent class method can be used as!

I understand the concept of inheritance, is the inheritance BaseException don't know what role, BaseException seems to be the father of all exceptions classes,