Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'operator': 0.05; 'python': 0.07; '21,': 0.09; 'equivalent.': 0.09; 'integers': 0.09; 'referencing': 0.09; 'pm,': 0.11; 'wrote:': 0.14; 'equal.': 0.16; 'subject:between': 0.16; 'subject:lines': 0.16; 'object,': 0.19; 'header:In-Reply-To:1': 0.22; 'thu,': 0.22; 'keeps': 0.24; 'objects': 0.24; "what's": 0.24; 'pointing': 0.25; 'compare': 0.26; "i'm": 0.26; 'instead': 0.26; 'chris': 0.27; 'object': 0.27; 'message-id:@mail.gmail.com': 0.28; "doesn't": 0.28; 'variables': 0.29; 'however,': 0.31; 'to:addr:python-list': 0.32; 'asking': 0.32; 'test': 0.33; 'rather': 0.36; 'hello,': 0.36; 'two': 0.37; 'received:209.85': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'used': 0.38; 'anything': 0.38; 'not,': 0.39; 'holding': 0.39; 'it!': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'would': 0.40; 'header:Received:5': 0.40; 'exact': 0.60; '2011': 0.62; 'subject:line': 0.73; 'subject:one': 0.73; 'guarantee': 0.75; 'received:209.85.210.174': 0.84; 'received:mail-iy0-f174.google.com': 0.84; 'subject:there': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=gOtqgmfXYH5MuvUoLbJYmasM95Vl2siu/EiW8F7akAI=; b=rvnabyeRiAmUFnLi03LR3JseHCPAljEI8Ij2qzhSPwRtlKBoRSkdDUi+5kX6DaHB+e QyfFo+cHvl/1d/BNFpVotK3RMwwsAFNZo2Efsv1+gs+0z2+80LtksYDZ5RKlyo2Ieaip fSYoI52Psnd9rOn6thRrr1vHPwj5sdoUXMkpo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=eEi3a+nY59NekEfXrTTrZ8gcpsu7rhYuoZrfD2GmRZdwVoYGAvmNCQ6d7bfK6igo83 OJR3sJJe7u3Jwl7wL83Gduns+ayee9luUlM4hLxWK3epvQZM+KveSJd1wgbJ3dOzhOBG fJqcgHhrm1rfXTcHi1RuDllwNODjJK08hjNZY= MIME-Version: 1.0 In-Reply-To: <336b2051-5ecb-4b50-af24-2f9181448822@glegroupsg2000goo.googlegroups.com> References: <336b2051-5ecb-4b50-af24-2f9181448822@glegroupsg2000goo.googlegroups.com> Date: Thu, 21 Apr 2011 19:47:07 +1000 Subject: Re: is there a difference between one line and many lines From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303379235 news.xs4all.nl 41102 [::ffff:82.94.164.166]:56423 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3777 On Thu, Apr 21, 2011 at 7:38 PM, vino19 wrote: > Hello, I'm a newbie. > What's the defference between > >>>>a=-6; b=-6; a is b >>>>True > > and > >>>>a=-6 >>>>b=-6 >>>>a is b >>>>False You may want to use the == operator rather than "is". When you use "is", you're asking Python if the two variables are referencing the exact same object, but with ==, you're asking if they're equivalent. With integers from -1 to 99, Python keeps singletons, which means that your test would work if you used 6 instead of -6; but there's no guarantee of anything with the negatives. However, it doesn't matter whether the variables are pointing to the same object or not, if you use ==, because two different objects holding the number -6 will compare equal. Hope that clarifies it! Chris Angelico