Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4231838
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:01:12+00:00 2026-05-21T02:01:12+00:00

Instead of ==? I know what is is, it is comparing the identity of

  • 0

Instead of “==”? I know what “is” is, it is comparing the identity of the variable. But when would you ever want to do that? All it has ever done for me is cause problems. After using it for a while (because I felt it made my code more readable), I am not declaring war on “is”.

Does anyone use it for something that “==” wouldn’t do? I don’t understand why they didn’t make ‘is’ the same thing as ‘==’, like they made ‘and’ the same as ‘&&’ etc. If someone wanted the pointer, they just have to say “id(x) == id(y)” and we wouldn’t have this confusion.

It’s one of the “gotcha’s” in python that I don’t understand, and trip a lot of newbies up. The reason I think it trips people up is that they don’t get why it would do an identity comparison. What is the point(er)?

Edit:
Thanks for the great answers. I think what new people should take away is “always use ‘==’ unless you know what you are doing”!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T02:01:13+00:00Added an answer on May 21, 2026 at 2:01 am

    Yes, there is a reason.

    When you want to compare object-identity (“same object”) and not object-equality (“same value”). In almost all cases == (object-equality) is the correct operator to use. (As pointed out in the comments, the trivial case I skipped entirely is the x is None idiom — None is the sole inhabitant of NoneType.)

    One case for object-identity is an identity-cache/dictionary which is a common pattern in some proxy or “inside-out” situations. In this case I don’t want the value for “a similar object” back, I want value for “the same object” back.

    Happy coding.


    Thinking about pointers in Python is wrong. Values in Python are objects and each value represents itself. That is, x is y is only true when x and y evaluate to the same object. When objects are passed in python this same concept holds — the object itself is passed. No need to think about references.

    Python is Call-by-Sharing/Call-by-Object-Sharing although the term “Call-By-Reference” — which exists in the “official documentation places” — is often incorrectly used to describe the behavior (perhaps to “ease” the transition from other languages where the term is also often incorrectly used).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i know that django uses unicode strings all over the framework instead of normal
I know that when comparing String s, you should use .equals() not == and
I know this has been asked about a million times over, however all the
Instead of just using urllib does anyone know of the most efficient package for
I know it is bad practice to use equality instead of equivalence when sorting
I know Apple is big on having you use NS objects instead of true
Does anyone know when XML should be used instead of JSON and why? Thanks
Does anyone know how to use an icon instead of text for the UINavigationController
Anyone know why Subsonic 2.2 uses System.Data.SQLite version 1.0.60.0 instead of the latest version
I know, if i will write redirect_to instead of render :action, i'll lose my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.