ArticleDirectory
- Standarderror
- Lookuperror
Update 2011-3-1.
Lai Yonghao (http://laiyonghao.com)
It's okay tonight. I read Python manuals and found a few neglected knowledge points, including standarderror and lookuperror.
Standarderror
Standarderror inherits from exception, which is the parent class of all built-in exception classes except stopiteration, generatorexit, keyboardinterrupt, and systemexit. I used to write thisCode:
Class myerror (exception): <br/> pass
Now, it is not correct. standarderror should be used as the base class of myerror. In addition, although I use very few Code such as counter t exception, most of them should use counter t standarderror.
Lookuperror
I don't know if you have written such code ..
Try: <br/> I = T [1] <br/> cannot t indexerror: <br/> I = default
On a certain day of a certain month, the T type is changed from a list-type sequence container to dict. It is too tricky to change all indexerrors to keyerror. I have done such a thing several times, and at that time I secretly scolded uncle turtles for several times ...... Okay, now I know it's my fault. Lookuperror is the base class of indexerror and keyerror. That is to say, if the above Code is counter t lookuperror, the type of t does not need to be changed. Wow ~
Well, I have read the manual tonight. In addition to the lessons learned, there are some other knowledge points, but it's too late. Let's talk about it again in another day.
Well, it's really time to read more manuals!