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 8022427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:15:54+00:00 2026-06-04T22:15:54+00:00

Possible Duplicate: Is there any difference between “foo is None” and “foo == None”?

  • 0

Possible Duplicate:
Is there any difference between “foo is None” and “foo == None”?

Quite a simple question really.

Whats the difference between:

if a.b is 'something':

and

if a.b == 'something':

excuse my ignorance

  • 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-06-04T22:15:55+00:00Added an answer on June 4, 2026 at 10:15 pm

    The first checks for identity the second for equality.

    Examples:

    The first operation using is may or may not result in True based on where these items, i.e., strings, are stored in memory.

    a='this is a very long string'
    b='this is a very long string'
    
    a is b
    False
    

    Checking, id() shows them stored at different locations.

    id(a)
    62751232
    
    id(b)
    62664432
    

    The second operation (==) will give True since the strings are equal.

    a == b
    True
    

    Another example showing that is can be True or False (compare with the first example), but == works the way we’d expect:

    '3' is '3'
    True
    

    this implies that both of these short literals were stored in the same memory location unlike the two longer strings in the example above.

    '3' == '3'
    True
    

    No surprise here, what we would have expected.

    I believe is uses id() to determine if the same objects in memory are referred to (see @SvenMarnach comment below for more details)

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

Sidebar

Related Questions

Possible Duplicate: what is “=null” and “ IS NULL” Is there any difference between
Possible Duplicate: C++: “std::endl” vs “n” I'm wondering if there is any significant difference
Possible Duplicates: Is there any difference between “string” and 'string' in Python? Single quotes
Possible Duplicate: Is there any difference between a GUID and a UUID? Whats the
Possible Duplicate: C# newbie: what’s the difference between “bool” and “bool?” ? Hi, While
Possible Duplicate: Is there any wisdom behind “and”, “or” operators in Ruby ? What
Possible Duplicate: Is there any particular difference between intval and (int)? These two statements
Possible Duplicate: Differences in string compare methods in C# Is there any difference between
Possible Duplicate: In Python, what is the difference between “.append()” and “+= []”? In
Possible Duplicate: Is there any difference between Group By and Distinct What's the difference

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.