print "Hello, World!"
;)
Hi, everyone, Venku (a.k.a Python Newb) here.
I just kind of randomly opened up Python today (I do that a lot), and I decided I would finally ask this:

What does the "is" statement do in Python 2.7.1 (if the ver# matters)?

I checked out the Python command line (used "help()" "modules" "is"), but it only gave a comparison to C and an unintelligible description of what it does. I have an extensive vocabulary, and I am great with grammar and spelling, but the terminology, like "collection" and "membership" confused me.

It appears to be used in boolean operations (equal, not equal, etc.).
I wouldn't call myself a programmer just yet, but I'm very interested in Python and think it could be applied effectively in many environments, as it's so flexible.

Basically, I'm asking for a n00b explanation of "is."
:P

The "is" statement should only be used when you want to check if
something is exactly and identical to None like "a is None" or "b is not None".
For everything else you should use == or !=.
There are some other use cases for "is", too.
But in general you shouldn't use "is".

You use 'is' to check the identity of objects ...

# 'is' checks object identities
# the id is a memory location
# in this case Python stores the 7 in the same location

a = 7
b = 7
print(id(a))   # 30626568
print(id(b))   # 30626568
print(a is b)  # True

Do not use 'is' instead of '==' (there can be some problems).

Thanks, you were both helpful!
I knew to use "==" but when I noticed the "is" statement I was confused.

Thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.