Python Experience Basics "7" Object-oriented correlation

Source: Internet
Author: User

Other related

One, isinstance (obj, CLS)

Checks if obj is an object of class CLS

1 class Foo (object): 2     Pass 3  4 obj = foo ()5  6 isinstance (obj, foo)

Second, Issubclass (sub, super)

Check if the sub class is a derived class of super class

1 class Foo (object): 2     Pass 3  4 class Bar (Foo): 5     Pass 6  7 Issubclass (Bar, Foo)

Third, exception handling

1. Abnormal Foundation

In the programming process in order to increase the friendliness of the program in the event of a bug will not be displayed to the user error message, but the reality of a hint of the page, popular is not to let users see the big Yellow Pages!!!

1 Try : 2     Pass 3 except Exception,ex: 4     Pass

Requirement: Add two numbers entered by the user

1  whileTrue:2NUM1 = Raw_input ('NUM1:')3num2 = Raw_input ('num2:')4     Try:5NUM1 =Int (NUM1)6num2 =Int (num2)7result = Num1 +num28     exceptException, E:9         Print 'An exception occurred with the following information:'Ten         PrintE
View Code

Python Experience Basics "7" Object-oriented correlation

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.