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

  • Home
  • SEARCH
  • 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 7070591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:35:06+00:00 2026-05-28T05:35:06+00:00

Why do I get differing results with these two examples of the is operator?

  • 0

Why do I get differing results with these two examples of the is operator?

>>> a = "1234"
>>> b = "1234"
>>> a is b
True
>>> a = "12 34"
>>> b = "12 34"
>>> a is b
False

What exactly does is do here? I understand that it is supposed to compare memory addresses, but I don’t see how that causes these results.

  • 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-28T05:35:07+00:00Added an answer on May 28, 2026 at 5:35 am

    is is not an equality operator. It checks to see if two variables refer to the same object. If you were to do this:

    a = "12 34'
    b = a
    

    then a is b would be True, since they refer to the same object.

    The cases you present are due to implementation details of the Python interpreter. Since strings are immutable, in some cases, creating two of the same string will yield references to the same object — i.e., in your first case, the Python interpreter only creates a single copy of "1234", and a and b both refer to that object. In the second case, the interpreter creates two copies. This is due to the way the interpreter creates and handles strings, and, as an implementation detail, should not be relied upon.

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

Sidebar

Related Questions

Can someone explain why I get different results from these two statements? I thought
Two Questions: Will I get different sequences of numbers for every seed I put
Here is an example to get different parts of a filename bash-3.2$ pathandfile=/tmp/ff.txt bash-3.2$
I must get two different client application talk without any kind of broker or
I am having some difficulty with these two functions: byteArrayToInt and intToByteArray . The
The second alternative ((1-9)(0-9)) of the following parser rule results in two nodes in
I want to get the difference in years from two different dates using MySQL
I'm trying to understand what the Java java.security.Signature class does. If I compute an
I'm wondering whether I will ever get a different result when producing a checksum
We are trying to get different SharePoint web applications to authenticate against different sub-domains.

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.