Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Python: Object identity

📅 2009-Sep-29 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ identity, objects, python ⬩ 📚 Archive

“id” prints the identity of an object

# "is" and "not is" operators check the object identity
a = 5
b = 5
id(a)      # 6701288
id(b)      # 6701288
a is b     # True
c = 4
a is c     # False
a is not c # True

© 2023 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 Mastodon📧 Email