{"id":113645,"date":"2025-11-26T15:42:52","date_gmt":"2025-11-26T10:12:52","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/?page_id=113645"},"modified":"2025-11-26T15:29:12","modified_gmt":"2025-11-26T09:59:12","slug":"python-identity-operators","status":"publish","type":"page","link":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/","title":{"rendered":"Python Identity Operators (is, is not)"},"content":{"rendered":"\n<h1 id=\"python-identity-operators-is-is-not\">Python Identity Operators (is, is not)<\/h1>\n\n<h2 id=\"what-are-identity-operators-in-python\">What Are Identity Operators in Python?<\/h2>\n<p>\n    Identity operators are keywords in <code>Python<\/code> that compare the memory locations of two objects. They check if two variables refer to the exact same object instance. This means you can tell if two variables are not just equal in value but are actually the same object.\n<\/p>\n<p>\n    For example, two different <code>lists<\/code> can contain the same elements but still be two separate objects in memory.\n<\/p>\n\n\n<h2 id=\"the-is-operator\">The \"is\" Operator<\/h2>\n<p>\n    The <code>is<\/code> operator returns <code>True<\/code> if both variables point to the exact same object in memory. If they point to different objects (even if their content is identical), it returns <code>False<\/code>. Think of it as asking, \"Do these two variables refer to the same thing?\"\n<\/p>\n<p>\n    Here's how it works with a <code>list<\/code>:\n<\/p>\n\n<div class=\"code-editor-container\">\n    <div id=\"editor-is\" class=\"python-code-editor\">\nlist_a = [1, 2, 3]\nlist_b = [1, 2, 3]  # A new list with the same values\nlist_c = list_a      # list_c now refers to the same object as list_a\n\n# Compare list_a and list_b\nprint(list_a is list_b)\n# Output: False\n\n# Compare list_a and list_c\nprint(list_a is list_c)\n# Output: True\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-is', 'output-is')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-is', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-is\" class=\"code-solution\">\n        <pre><code>list_a = [1, 2, 3]\nlist_b = [1, 2, 3]\nlist_c = list_a\n\nprint(list_a is list_b)\nprint(list_a is list_c)<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-is\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-is\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<p>\n    In this example, <code>list_a<\/code> and <code>list_b<\/code> have identical content but are separate objects, so <code>is<\/code> returns <code>False<\/code>. However, <code>list_c<\/code> was assigned directly from <code>list_a<\/code>, so they both point to the same object, and <code>is<\/code> returns <code>True<\/code>.\n<\/p>\n\n<h2 id=\"the-is-not-operator\">The \"is not\" Operator<\/h2>\n<p>\n    The <code>is not<\/code> operator is the opposite of the <code>is<\/code> operator. It returns <code>True<\/code> if both variables point to different objects in memory. If they point to the same object, it returns <code>False<\/code>. This operator asks, \"Are these two variables different objects?\"\n<\/p>\n<p>\n    Let's use the same lists from the previous example:\n<\/p>\n\n<div class=\"code-editor-container\">\n    <div id=\"editor-is-not\" class=\"python-code-editor\">\nlist_a = [1, 2, 3]\nlist_b = [1, 2, 3]\nlist_c = list_a\n\n# Compare list_a and list_b\nprint(list_a is not list_b)\n# Output: True\n\n# Compare list_a and list_c\nprint(list_a is not list_c)\n# Output: False\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-is-not', 'output-is-not')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-is-not', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-is-not\" class=\"code-solution\">\n        <pre><code>list_a = [1, 2, 3]\nlist_b = [1, 2, 3]\nlist_c = list_a\n\nprint(list_a is not list_b)\nprint(list_a is not list_c)<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-is-not\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-is-not\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<p>\n    Since <code>list_a<\/code> and <code>list_b<\/code> are separate objects, <code>is not<\/code> correctly returns <code>True<\/code>. Because <code>list_a<\/code> and <code>list_c<\/code> refer to the same object, <code>is not<\/code> returns <code>False<\/code>.\n<\/p>\n\n<h2 id=\"identity-vs-equality-is-vs\">Identity vs. Equality: is vs. ==<\/h2>\n<p>\n    A common source of confusion is the difference between the <code>is<\/code> operator and the <code>==<\/code> operator. While <code>is<\/code> checks for object identity, <code>==<\/code> checks for value equality. This is a critical distinction in <code>Python<\/code>.\n<\/p>\n<ul>\n    <li><strong><code>is<\/code> (Identity):<\/strong> Checks if two variables point to the <em>same memory location<\/em>.<\/li>\n    <li><strong><code>==<\/code> (Equality):<\/strong> Checks if the <em>values<\/em> of the objects are the same.<\/li>\n<\/ul>\n<p>\n    Let's revisit our list example to see the difference clearly.\n<\/p>\n\n<div class=\"code-editor-container\">\n    <div id=\"editor-diff\" class=\"python-code-editor\">\nlist_a = [1, 2, 3]\nlist_b = [1, 2, 3]\n\n# Identity check\nprint(f\"Identity check (is): {list_a is list_b}\")\n# Output: Identity check (is): False\n\n# Equality check\nprint(f\"Equality check (==): {list_a == list_b}\")\n# Output: Equality check (==): True\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-diff', 'output-diff')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-diff', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-diff\" class=\"code-solution\">\n        <pre><code>list_a = [1, 2, 3]\nlist_b = [1, 2, 3]\n\nprint(f\"Identity check (is): {list_a is list_b}\")\nprint(f\"Equality check (==): {list_a == list_b}\")<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-diff\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-diff\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<p>\n    The <code>is<\/code> operator returns <code>False<\/code> because <code>list_a<\/code> and <code>list_b<\/code> are two separate list objects stored in different memory locations. The <code>==<\/code> operator returns <code>True<\/code> because the content of both lists is identical.\n<\/p>\n\n<h2 id=\"when-to-use-identity-operators\">When to Use Identity Operators<\/h2>\n<p>\n    Use identity operators in specific situations where you need to check for object identity, not value. The most common and recommended use cases are:\n<\/p>\n<ul>\n    <li><strong>Check for <code>None<\/code>:<\/strong> Use <code>is<\/code> to check if a variable is <code>None<\/code>. Because <code>None<\/code> is a singleton object (only one instance exists), <code>is<\/code> is both faster and more explicit.<\/li>\n    <li><strong>Compare to singletons:<\/strong> Use <code>is<\/code> when comparing to other singletons like <code>True<\/code> and <code>False<\/code>. For example, <code>if my_variable is True:<\/code>.<\/li>\n    <li><strong>Verify specific object instances:<\/strong> Use it when your program's logic depends on knowing if you're working with the exact same object instance.<\/li>\n<\/ul>\n\n<div class=\"code-editor-container\">\n    <div id=\"editor-none\" class=\"python-code-editor\">\ndef my_function(value):\n    if value is None:\n        print(\"No value was provided.\")\n    else:\n        print(f\"The value is {value}.\")\n\nmy_function(\"hello\")\n# Output: The value is hello.\n\nmy_function(None)\n# Output: No value was provided.\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-none', 'output-none')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-none', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-none\" class=\"code-solution\">\n        <pre><code>def my_function(value):\n    if value is None:\n        print(\"No value was provided.\")\n    else:\n        print(f\"The value is {value}.\")\n\nmy_function(\"hello\")\nmy_function(None)<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-none\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-none\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n\n<h2 id=\"a-common-pitfall-pythons-caching-behavior\">A Common Pitfall: Python's Caching Behavior<\/h2>\n<p>\n    You might see situations where <code>is<\/code> returns <code>True<\/code> unexpectedly, especially with numbers and short strings. This happens because <code>Python<\/code> caches (or \"interns\") certain immutable objects for performance reasons.\n<\/p>\n<p>\n    For example, <code>Python<\/code> pre-allocates integer objects from -5 to 256. When you create an integer in this range, <code>Python<\/code> points the variable to the existing cached object instead of creating a new one.\n<\/p>\n\n<div class=\"code-editor-container\">\n    <div id=\"editor-cache\" class=\"python-code-editor\">\n# Integers in the cached range (-5 to 256)\na = 256\nb = 256\nprint(a is b)\n# Output: True\n\n# Integers outside the cached range\nx = 257\ny = 257\nprint(x is y)\n# Output: False\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-cache', 'output-cache')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-cache', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-cache\" class=\"code-solution\">\n        <pre><code># Integers in the cached range (-5 to 256)\na = 256\nb = 256\nprint(a is b)\n\n# Integers outside the cached range\nx = 257\ny = 257\nprint(x is y)<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-cache\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-cache\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<p>\n    This behavior is an implementation detail of the CPython interpreter and can change. Never rely on it. Always use <code>==<\/code> to compare numerical values. This shows why it's crucial to use <code>is<\/code> only for true identity checks, like with <code>None<\/code>.\n<\/p>\n\n<h2 id=\"final-challenge-the-clone-checker\">Final Challenge: The Clone Checker<\/h2>\n<p>\n    Prove your understanding of <code>is<\/code> versus <code>==<\/code>.\n<\/p>\n<p>Your Task:<\/p>\n<ol>\n    <li>Create two lists, <code>x<\/code> and <code>y<\/code>, that both contain <code>[10, 20]<\/code>.<\/li>\n    <li>Create a variable <code>z<\/code> and assign <code>x<\/code> to it (<code>z = x<\/code>).<\/li>\n    <li>Check if <code>x<\/code> equals <code>y<\/code> (Value equality).<\/li>\n    <li>Check if <code>x<\/code> is <code>y<\/code> (Object identity).<\/li>\n    <li>Check if <code>x<\/code> is <code>z<\/code> (Object identity).<\/li>\n<\/ol>\n\n<div class=\"code-editor-container\">\n    <div id=\"editor-final\" class=\"python-code-editor\">\n# TODO: Create lists x and y\n# x = ...\n# y = ...\n\n# TODO: Create z\n# z = ...\n\n# TODO: Print comparisons\n# print(\"x == y:\", ...)\n# print(\"x is y:\", ...)\n# print(\"x is z:\", ...)\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-final', 'output-final')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-final', this)\">Show Solution<\/button>\n    <\/div>\n\n    <div id=\"solution-final\" class=\"code-solution\">\n        <pre><code>x = [10, 20]\ny = [10, 20]\nz = x\n\nprint(\"x == y:\", x == y)\nprint(\"x is y:\", x is y)\nprint(\"x is z:\", x is z)<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-final\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-final\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<div class=\"cta-final\">\n    <div class=\"cta-final-header\">\n        <span class=\"cta-final-trophy\">\ud83c\udfc6<\/span>\n        <h2 id=\"lesson-completed\">Lesson Completed<\/h2>\n    <\/div>\n\n    <p class=\"cta-final-intro\">\n        You have successfully learned about Python Identity Operators, the difference between equality and identity, and Python's object caching.\n    <\/p>\n\n    <div class=\"cta-final-grid\">\n        <div class=\"cta-final-option\">\n            <div class=\"cta-final-option-header\">\n                <span>\ud83d\udcd8<\/span>\n                <h4 id=\"full-python-course\">Full Python Course<\/h4>\n            <\/div>\n            <p>Master Python with 11+ hours of content, 50+ exercises, and real-world projects.<\/p>\n            <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/master-python-programming?utm_source=blog\" class=\"cta-final-button-primary\">Enroll Now<\/a>\n        <\/div>\n\n        <div class=\"cta-final-option\" id=\"pt-next-lesson-container\">\n            <div class=\"cta-final-option-header\">\n                <span>\ud83d\udcdd<\/span>\n                <h4 id=\"next-lesson\">Next Lesson<\/h4>\n            <\/div>\n            <p id=\"pt-next-lesson-text\">Continue with the next lesson on Python Membership Operators.<\/p>\n            <a href=\"#\" id=\"pt-next-lesson-button\" class=\"cta-final-button-secondary\">Next Lesson -><\/a>\n        <\/div>\n    <\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Learn Python identity operators. Understand object identity, value equality, memory comparison, when to use them, and how they differ from equality operators.<\/p>\n","protected":false},"author":41,"featured_media":113656,"parent":113156,"menu_order":18,"comment_status":"closed","ping_status":"closed","template":"templates\/python-tutorial.php","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[36796,36893],"class_list":["post-113645","page","type-page","status-publish","has-post-thumbnail","hentry","category-software","tag-python","tag-python-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python Identity Operators (is, is not)<\/title>\n<meta name=\"description\" content=\"Learn Python identity operators. Understand object identity, value equality, memory comparison, when to use them, and how they differ from equality operators.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Identity Operators (is, is not)\" \/>\n<meta property=\"og:description\" content=\"Learn Python identity operators. Understand object identity, value equality, memory comparison, when to use them, and how they differ from equality operators.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1408\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-identity-operators\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-identity-operators\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Python Identity Operators (is, is not)\",\"datePublished\":\"2025-11-26T10:12:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-identity-operators\\\/\"},\"wordCount\":847,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-identity-operators\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/python-identity-operators.webp\",\"keywords\":[\"python\",\"python-tutorial\"],\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-identity-operators\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-identity-operators\\\/\",\"name\":\"Python Identity Operators (is, is not)\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-identity-operators\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-identity-operators\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/python-identity-operators.webp\",\"datePublished\":\"2025-11-26T10:12:52+00:00\",\"description\":\"Learn Python identity operators. Understand object identity, value equality, memory comparison, when to use them, and how they differ from equality operators.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-identity-operators\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-identity-operators\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-identity-operators\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/python-identity-operators.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/python-identity-operators.webp\",\"width\":1408,\"height\":768,\"caption\":\"Python Identity Operators\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-identity-operators\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Tutorial\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python Identity Operators (is, is not)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Identity Operators (is, is not)","description":"Learn Python identity operators. Understand object identity, value equality, memory comparison, when to use them, and how they differ from equality operators.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/","og_locale":"en_US","og_type":"article","og_title":"Python Identity Operators (is, is not)","og_description":"Learn Python identity operators. Understand object identity, value equality, memory comparison, when to use them, and how they differ from equality operators.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","og_image":[{"width":1408,"height":768,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators.webp","type":"image\/webp"}],"twitter_card":"summary_large_image","twitter_site":"@Great_Learning","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Python Identity Operators (is, is not)","datePublished":"2025-11-26T10:12:52+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/"},"wordCount":847,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators.webp","keywords":["python","python-tutorial"],"articleSection":["IT\/Software Development"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/","url":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/","name":"Python Identity Operators (is, is not)","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators.webp","datePublished":"2025-11-26T10:12:52+00:00","description":"Learn Python identity operators. Understand object identity, value equality, memory comparison, when to use them, and how they differ from equality operators.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators.webp","width":1408,"height":768,"caption":"Python Identity Operators"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-identity-operators\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Python Tutorial","item":"https:\/\/www.mygreatlearning.com\/blog\/python\/"},{"@type":"ListItem","position":3,"name":"Python Identity Operators (is, is not)"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators.webp",1408,768,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators-150x150.webp",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators-300x164.webp",300,164,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators-768x419.webp",768,419,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators-1024x559.webp",1024,559,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators.webp",1408,768,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators.webp",1408,768,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators-640x768.webp",640,768,true],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators-96x96.webp",96,96,true],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-identity-operators-150x82.webp",150,82,true]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"Learn Python identity operators. Understand object identity, value equality, memory comparison, when to use them, and how they differ from equality operators.","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/113645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=113645"}],"version-history":[{"count":11,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/113645\/revisions"}],"predecessor-version":[{"id":113650,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/113645\/revisions\/113650"}],"up":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/113156"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/113656"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=113645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=113645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=113645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}