Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #16271

Re: Pragmatics of the is operator

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.047
X-Spam-Evidence '*H*': 0.91; '*S*': 0.00; '"if': 0.04; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'spam"': 0.16; 'meant': 0.17; "wouldn't": 0.17; 'wrote:': 0.18; 'reason,': 0.18; 'header:In- Reply-To:1': 0.22; 'message-id:@mail.gmail.com': 0.28; '27,': 0.29; 'nov': 0.29; 'pm,': 0.29; 'sun,': 0.30; 'equivalent': 0.31; 'quite': 0.32; 'actually': 0.33; 'to:addr:python-list': 0.34; 'checks': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'form,': 0.39; "it's": 0.40; 'received:209': 0.40; 'to:addr:python.org': 0.40; '2011': 0.61; '12:42': 0.84; 'candide': 0.84; 'different.': 0.84; 'unclear': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=mkmzevZ3mqXTXytFXeVnB+I1og8ilFBCLRFzexrxwoc=; b=Dcl+Wdv8gKLcTrTyRIN8M3P1aVAUne1eZ2K77oWJdTpmlFfl+sCaDQyok/W3R+O+q4 KrxWrwQC6jnCBVod5OjJtQZ9I/ltRCUpmH+0MTDfLgvl9KQM+KsOYvweF0LaBQ/CTeWu /BR/sIljwG283/3EUxaz5cMzNG/nRA1Hp1LGQ=
MIME-Version 1.0
In-Reply-To <4ed1959d$0$690$426a74cc@news.free.fr>
References <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed1959d$0$690$426a74cc@news.free.fr>
Date Sun, 27 Nov 2011 12:50:52 +1100
Subject Re: Pragmatics of the is operator
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3063.1322358656.27778.python-list@python.org> (permalink)
Lines 12
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1322358656 news.xs4all.nl 6933 [2001:888:2000:d::a6]:37613
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:16271

Show key headers only | View raw


On Sun, Nov 27, 2011 at 12:42 PM, candide <candide@free.invalid> wrote:
> So, for the same reason, wouldn't it be better to use "if spam is True"
> against to "if spam == True"  (or better "if spam") ?
>

They're quite different. "if spam" will check the truthiness of spam -
it's equivalent to "if bool(spam) is True"; "if spam is True" checks
that it's actually a boolean. But I would recommend against the "==
True" form, as it's unclear which form you meant to use. (Others may
disagree.)

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Pragmatics of the standard is() function candide <candide@free.invalid> - 2011-11-26 22:20 +0100
  Re: Pragmatics of the standard is() function Roy Smith <roy@panix.com> - 2011-11-26 16:32 -0500
  Re: Pragmatics of the standard is() function Chris Angelico <rosuav@gmail.com> - 2011-11-27 09:22 +1100
  Re: Pragmatics of the standard is() function Alexander Kapps <alex.kapps@web.de> - 2011-11-26 23:38 +0100
  Re: Pragmatics of the standard is() function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-26 23:01 +0000
    Re: Pragmatics of the is operator candide <candide@free.invalid> - 2011-11-27 02:42 +0100
      Re: Pragmatics of the is operator Chris Angelico <rosuav@gmail.com> - 2011-11-27 12:50 +1100
      Re: Pragmatics of the is operator Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-27 03:13 +0000
    Re: Pragmatics of the standard is() function Den <patentsvnc@gmail.com> - 2011-11-28 11:22 -0800
      Re: Pragmatics of the standard is() function Ethan Furman <ethan@stoneleaf.us> - 2011-11-28 12:05 -0800
      Re: Pragmatics of the standard is() function alex23 <wuwei23@gmail.com> - 2011-11-28 19:58 -0800
      Re: Pragmatics of the standard is() function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-29 08:41 +0000
        Re: Pragmatics of the standard is() function Den <patentsvnc@gmail.com> - 2011-11-29 09:11 -0800
  Re: Pragmatics of the standard is() function Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-11-28 13:57 +0100

csiph-web