Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #67591
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python.list@tim.thechases.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'else:': 0.03; 'element': 0.07; 'none:': 0.07; 'lawrence': 0.09; 'lst': 0.09; 'python': 0.11; 'def': 0.12; 'times,': 0.14; '"is"': 0.16; '-tkc': 0.16; '10+': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'object()': 0.16; 'obsessed': 0.16; 'sentinel': 0.16; 'usage,': 0.16; 'prevent': 0.16; 'wrote:': 0.18; 'recognize': 0.24; "i've": 0.25; 'header:In-Reply-To:1': 0.27; '(which': 0.31; 'skip:d 20': 0.34; "i'd": 0.34; 'but': 0.35; 'there': 0.35; 'described': 0.36; 'done': 0.36; 'doing': 0.36; 'charset:us-ascii': 0.36; 'too': 0.37; 'needed': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'most': 0.60; 'such': 0.63; 'effectively': 0.66; '95%': 0.84; 'kiss': 0.84; 'often?': 0.84; 'received:50.22': 0.84; 'touching': 0.84 |
| Date | Mon, 3 Mar 2014 15:51:12 -0600 |
| From | Tim Chase <python.list@tim.thechases.com> |
| To | python-list@python.org |
| Subject | Re: Reference |
| In-Reply-To | <lf2sjk$7d4$1@ger.gmane.org> |
| References | <53144e8d$0$2149$426a74cc@news.free.fr> <1d1dfa1b-b715-4d8f-9c12-f0d3dc1a22c9@googlegroups.com> <85ppm3httu.fsf@benfinney.id.au> <lf2sjk$7d4$1@ger.gmane.org> |
| X-Mailer | Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-AntiAbuse | This header was added to track abuse, please include it with any abuse report |
| X-AntiAbuse | Primary Hostname - boston.accountservergroup.com |
| X-AntiAbuse | Original Domain - python.org |
| X-AntiAbuse | Originator/Caller UID/GID - [47 12] / [47 12] |
| X-AntiAbuse | Sender Address Domain - tim.thechases.com |
| X-Get-Message-Sender-Via | boston.accountservergroup.com: authenticated_id: tim@thechases.com |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7664.1393883448.18130.python-list@python.org> (permalink) |
| Lines | 43 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1393883448 news.xs4all.nl 2869 [2001:888:2000:d::a6]:35388 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:67591 |
Show key headers only | View raw
On 2014-03-03 21:35, Mark Lawrence wrote:
> I'd just like to know why people are so obsessed with identities,
> I've never thought to use them in 10+ years of writing Python. Do
> I use the KISS principle too often?
There are a couple use-cases I've encountered where "is" matters:
1) the most popular:
if foo is None:
do_stuff()
2) sentinels (which are effectively non-None None values)
SENTINEL = object()
def myfuntion(value=SENTINEL):
if value is SENTINEL:
do_something_parameterless()
else:
do_something_else(value) # allow for value=None
3) when doing recursion and you want to prevent touching the same
object multiple times, such as what happens when you do
lst = [1,2,3]
lst.append(lst)
print(lst)
and it needs to recognize that the final element of "lst" is one that
it has already seen (as done by identity).
There might be some other use cases, but #1 is a good 95% of my
usage, #2 is a good 4%, and I can only think of once in my Python
career when I've needed to do what is described in #3.
-tkc
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Reference "ast" <nomail@invalid.com> - 2014-03-03 10:42 +0100
Object identity (was: Reference) Ben Finney <ben+python@benfinney.id.au> - 2014-03-03 21:00 +1100
Re: Object identity (was: Reference) "ast" <nomail@invalid.com> - 2014-03-03 11:21 +0100
Re: Reference "Mark H. Harris" <harrismh777@gmail.com> - 2014-03-03 05:09 -0800
Re: Reference Grant Edwards <invalid@invalid.invalid> - 2014-03-03 14:29 +0000
Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-03 07:52 -0800
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-04 08:10 +1100
Re: Reference Tim Chase <python.list@tim.thechases.com> - 2014-03-03 15:24 -0600
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-04 08:31 +1100
Re: Reference Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-03 21:35 +0000
Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-04 00:07 +0200
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-04 09:18 +1100
Re: Reference Alister <alister.ware@ntlworld.com> - 2014-03-04 11:10 +0000
Re: Reference Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-04 11:48 +0000
Re: Reference "Rhodri James" <rhodri@wildebst.org.uk> - 2014-03-05 00:25 +0000
Re: Reference Tim Chase <python.list@tim.thechases.com> - 2014-03-03 15:51 -0600
Re: Reference Jerry Hill <malaclypse2@gmail.com> - 2014-03-03 17:02 -0500
Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-04 00:22 +0200
Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-04 09:27 +1100
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-04 09:33 +1100
Re: Reference Steven D'Aprano <steve@pearwood.info> - 2014-03-04 04:52 +0000
Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-04 16:24 +1100
Re: Reference "Rhodri James" <rhodri@wildebst.org.uk> - 2014-03-05 01:08 +0000
Re: Reference Roy Smith <roy@panix.com> - 2014-03-04 21:09 -0500
Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 19:36 -0800
Re: Reference Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-04 21:08 -0700
Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 20:31 -0800
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-05 15:32 +1100
Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 20:47 -0800
Re: Reference Steven D'Aprano <steve@pearwood.info> - 2014-03-05 05:06 +0000
Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 21:47 -0800
Re: Reference alex23 <wuwei23@gmail.com> - 2014-03-05 16:01 +1000
Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 22:10 -0800
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-05 17:22 +1100
Re: Reference alex23 <wuwei23@gmail.com> - 2014-03-05 16:28 +1000
Re: Reference Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-05 12:24 +0000
Re: Reference Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-05 12:21 +0000
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-05 17:20 +1100
Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-05 09:40 -0800
Re: Reference Tim Chase <python.list@tim.thechases.com> - 2014-03-05 12:12 -0600
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-06 05:33 +1100
Re: Reference Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-05 18:19 +0000
Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-05 22:23 +0200
Re: Reference Grant Edwards <invalid@invalid.invalid> - 2014-03-05 20:31 +0000
Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-05 22:46 +0200
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-06 08:07 +1100
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-06 08:10 +1100
Re: Reference Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-05 21:34 +0000
Re: Reference Terry Reedy <tjreedy@udel.edu> - 2014-03-05 18:00 -0500
Re: Reference Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-06 03:01 +0000
Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 22:03 -0800
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-05 17:26 +1100
Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-05 17:32 +1100
Re: Reference Tim Chase <python.list@tim.thechases.com> - 2014-03-05 08:24 -0600
Re: Reference Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-05 18:29 +0000
Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-05 22:34 +0200
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-06 08:01 +1100
Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-05 23:14 +0200
Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-06 08:26 +1100
Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-05 23:50 +0200
Re: Reference Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-06 00:35 +0000
Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-06 11:50 +1100
Re: Reference Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-06 17:46 +0000
Re: Reference Tim Chase <python.list@tim.thechases.com> - 2014-03-05 15:33 -0600
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-06 08:37 +1100
Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-06 02:52 +0200
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-06 12:05 +1100
Re: Reference alex23 <wuwei23@gmail.com> - 2014-03-06 12:12 +1000
Re: Reference Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-05 21:46 +0000
Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-05 08:23 +0200
Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 22:33 -0800
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-05 17:40 +1100
Re: Reference Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-05 12:35 +0000
Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-05 23:45 +1100
Re: Reference Jerry Hill <malaclypse2@gmail.com> - 2014-03-04 10:19 -0500
Re: Reference Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-04 15:42 +0000
Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-05 03:02 +1100
Re: Reference Roy Smith <roy@panix.com> - 2014-03-04 11:14 -0500
Re: Reference MRAB <python@mrabarnett.plus.com> - 2014-03-04 17:12 +0000
Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 08:24 -0800
Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-05 02:25 +1100
Re: Reference Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2014-03-05 14:37 +0100
Re: Reference Steven D'Aprano <steve@pearwood.info> - 2014-03-04 03:59 +0000
Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-04 09:17 +1100
Re: Reference Roy Smith <roy@panix.com> - 2014-03-03 18:02 -0500
Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-04 10:09 +1100
Re: Reference Steven D'Aprano <steve@pearwood.info> - 2014-03-04 04:38 +0000
Re: Reference Terry Reedy <tjreedy@udel.edu> - 2014-03-03 13:48 -0500
Re: Reference Steven D'Aprano <steve@pearwood.info> - 2014-03-04 03:45 +0000
Re: Reference Alexander Blinne <news@blinne.net> - 2014-03-04 13:55 +0100
Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-05 01:06 +1100
Re: Reference Alexander Blinne <news@blinne.net> - 2014-03-04 22:53 +0100
Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-05 09:01 +1100
csiph-web