Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between `is` and `==`? [duplicate]

Tags:

python

syntax

Possible Duplicate:
Python ‘==’ vs ‘is’ comparing strings, ‘is’ fails sometimes, why?

In Python, what is the difference between these two statements:

if x is "odp":

if x == "odp":

like image 776
Nick Heiner Avatar asked Mar 10 '10 18:03

Nick Heiner


People also ask

Is duplicate means fake?

A “duplicate” refers to an exact copy of something. “Fake” refers to something being artificial or false. For example, if I print the same document twice, that's a duplicate; however, if I print the text of the constitution and say it's the original constitution, that's fake.

Is in duplicate meaning?

Definition of in duplicate 1 : so that there are two copies We were required to fill out the paperwork in duplicate. 2 : with an exact copy Please send the contract in duplicate.

Is reproduce the same as duplicate?

A duplicate is an exact copy. A reproduction is a close copy, and especially one made after the original is no longer available.

Is duplicate document same as original?

More Definitions of Duplicate originalDuplicate original means an exact copy of a signed original, an exact copy with signatures created by the same impression as the original, or an exact copy bearing an original signature. Duplicate original .


1 Answers

The == operator tests for equality

The is keyword tests for object identity; whether we are talking about the same object. Note that multiple variables may refer to the same object.

like image 163
Justin Ethier Avatar answered Oct 04 '22 08:10

Justin Ethier