Python function ID ()

Source: Internet
Author: User

ID (object)

function: returns the "Social Security Number" of the object, unique and unchanging, but the same ID value may appear during a non-coincident life cycle. The object mentioned here should refer specifically to objects of compound types (such as classes, lists, etc.), and for strings, integers, and so on, the ID of the variable changes with the value.

1 classObj ():2     def __init__(self,arg):3self.x=Arg4 if __name__=='__main__':  5        6Obj=obj (1)  7     PrintID (obj)#327544328obj.x=29     PrintID (obj)#32754432Ten         Ones="ABC"   A     PrintID (s)#140190448953184 -s="BCD"   -     PrintID (s)#32809848 the         -X=1 -     PrintID (x)#15760488 -x=2 +     PrintID (x)#15760464

Note:

To determine if two objects are equal, this is the ID value

The difference between IS and = = is that it is an in- memory comparison, and = = is a comparison of values

Python function ID ()

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.