Python Object Basics

Source: Internet
Author: User

    1. Three attributes of an object: identity, type, and value

Identity: Uniquely identifies an object that can be obtained using the ID ()

Type: What type of value is saved, the actions that can be made, and the rules that follow. You can use the type () to get the inverse value for the type Object

Value: The data item represented by the object

Three attributes are assigned when an object is created, and the identity and type attributes are read-only. For new style types and classes, the type of the object can also be changed

Object variability: Refers to whether the value of an object can be changed

2, the bool value of the following object is False

0.00.0+0.0j""

The Boolean value of an object that is not a value other than the one listed above is True, such as Non-empty, Non-zero, and so on. A user-created class instance whose Boolean value is False if nonzero (__nonzero__ ()) or length (__len__ ()) is defined and the value is 0.

Objects want to wait for judgment:

A is B #a和b是否是同一对象
This expression is equivalent to the following expression
ID (a) = = ID (b)

Python Object Basics

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.