An example of how to use the identity operator in Python

Source: Internet
Author: User
Python identity operator
The identity operator is used to compare the storage units of two objects

The following example demonstrates the operation of all Python identity operators:

#!/usr/bin/pythona = 20b = 20if (A is b):  print "line 1-a and B has same identity" else:  print "line 1-a and  b does not have same identity "if (ID (a) = = ID (b)):  print" line 2-a and B has same identity "else:  print" Line 2 -A and B do not have the same identity "B = 30if (A is b):  print" line 3-a and B has same identity "else:  print" Line 3-a and B does not have the same identity "if (A is not B): The print" line 4-a and B does not have  same identity "else:< C8/>print "line 4-a and B has same identity"

The result of the above example output:

 
  • Related Article

    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.