Introduction to three types of Python types

Source: Internet
Author: User

The Object System in the Python type perspective needs to be continuously learned, and we should pay attention to it when using it. Next we will look at how we can better use the Python type class. The following articles hope you will gain some benefits.

In a simple world of Python type, everything is an object. These objects can be divided into three types,

Metaclasses, classes, instance

Classes can be divided into built-in type and user-defined class.

The following is a detailed description of the image.

The definition of C is as follows (python inherits from a class and is directly written in parentheses after the class name ):

Class C (object):... the solid line indicates the relationship between is-kind-of, and the dotted line indicates the relationship between is-instance-.

When you view the base class of the current classes object (the instances object does not have the _ bases _ attribute), you can use classes_name. _ bases _. The value is a Tuple (Python supports multi-inheritance ).

The method for viewing the type of the current object is object_name. _ class __

We can use some tests to confirm the above figure:

All classes in the Python type class.

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.