Standarderror and lookuperror

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.