Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105694
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ethan Furman <ethan@stoneleaf.us> |
| Newsgroups | comp.lang.python |
| Subject | Re: Effects of caching frequently used objects, was Re: Explaining names vs variables in Python |
| Date | Fri, 25 Mar 2016 09:45:10 -0700 |
| Lines | 52 |
| Message-ID | <mailman.4.1458924289.28225.python-list@python.org> (permalink) |
| References | <nb6aqh$dp5$1@ger.gmane.org> <DUB123-W22AD13A14B7564949220F683830@phx.gbl> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de PXN/az9m43tK8/ssXupwBwFsalpHZEDVq9hAr54ZOPag== |
| Return-Path | <ethan@stoneleaf.us> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'true,': 0.04; 'subject:Python': 0.05; 'none,': 0.05; 'one?': 0.05; 'important,': 0.07; 'enum': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'none.': 0.09; 'objects.': 0.09; 'variables,': 0.09; 'python': 0.10; 'argument': 0.15; 'subject: \n ': 0.15; '"is"': 0.16; "(it's": 0.16; ':))': 0.16; 'ellipsis': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'singleton': 0.16; 'wrote:': 0.16; "shouldn't": 0.18; '>>>': 0.20; 'assign': 0.22; 'names.': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; '(such': 0.27; 'correct': 0.28; 'consistency': 0.29; 'expose': 0.29; 'party,': 0.29; '~ethan~': 0.29; 'objects': 0.29; 'somebody': 0.30; 'another': 0.32; 'etc.)': 0.32; 'getting': 0.33; 'false': 0.35; 'identity': 0.35; 'according': 0.36; 'but': 0.36; 'should': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'late': 0.38; 'names': 0.38; 'someone': 0.38; 'does': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'behavior': 0.61; 'subject: ': 0.61; 'no.': 0.62; 'back': 0.62; 'charset:windows-1252': 0.62; 'member,': 0.67 |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
| In-Reply-To | <DUB123-W22AD13A14B7564949220F683830@phx.gbl> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| 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> |
| Xref | csiph.com comp.lang.python:105694 |
Show key headers only | View raw
On 03/25/2016 06:03 AM, Albert-Jan Roskam wrote: > Somebody wrote: >> Somebody else wrote: >>> I know Python does not have variables, but names. >>> Multiple names cant then be bound to the same objects. >>> >>> So this behavior >>> >>>--> b = 234 >>>--> v = 234 >>>--> b is v >>> True >>> >>> according to the above that is ok >>> >>> >>> >>> But where is the consistency ? if I try : >>> >>>--> v = 890 >>>--> w = 890 >>>--> v is w >>> False >>> >>> It is a little difficult to explain this behavior to a newcommer in Python >>> >>> Can someone give me the right argument to expose ? >> >> You should not bother with object identity for objects other than None. No. The correct answer is: if identity is important either ensure the object you are getting back is a singleton (such as None, True, an Enum member, etc.) or you assign one name from another name: --> b = 234 --> v = b --> b is v True --> v = 890 --> w = v --> v is w True If identity is not important, don't use `is`. > A little late to the party, but: how about Ellipsis? Shouldn't "is" also be used for that one? (It's rare, I know :)) Ellipsis is a singleton, so `is` is fine. -- ~Ethan~
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Explaining names vs variables in Python Salvatore DI DIO <salvatore.didio@gmail.com> - 2016-03-02 00:32 -0800
Re: Explaining names vs variables in Python Jesper K Brogaard <jesper@brogAAaard.eu> - 2016-03-02 10:03 +0100
Re: Explaining names vs variables in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-02 21:32 +1100
Re: Explaining names vs variables in Python Marko Rauhamaa <marko@pacujo.net> - 2016-03-02 14:34 +0200
Re: Explaining names vs variables in Python Chris Angelico <rosuav@gmail.com> - 2016-03-02 23:50 +1100
Re: Explaining names vs variables in Python Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-03-02 15:11 +0200
Re: Explaining names vs variables in Python Marko Rauhamaa <marko@pacujo.net> - 2016-03-02 15:39 +0200
Re: Explaining names vs variables in Python Chris Angelico <rosuav@gmail.com> - 2016-03-03 00:48 +1100
Re: Explaining names vs variables in Python Marko Rauhamaa <marko@pacujo.net> - 2016-03-02 16:11 +0200
Re: Explaining names vs variables in Python Rustom Mody <rustompmody@gmail.com> - 2016-03-02 07:08 -0800
Re: Explaining names vs variables in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-03 04:23 +1100
Re: Explaining names vs variables in Python Rustom Mody <rustompmody@gmail.com> - 2016-03-02 09:28 -0800
Re: Explaining names vs variables in Python Marko Rauhamaa <marko@pacujo.net> - 2016-03-02 20:12 +0200
Re: Explaining names vs variables in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-03 12:52 +1100
Re: Explaining names vs variables in Python Rustom Mody <rustompmody@gmail.com> - 2016-03-03 09:03 -0800
Re: Explaining names vs variables in Python Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-03 12:53 -0700
Re: Explaining names vs variables in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-02 21:49 +0000
Re: Explaining names vs variables in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-03 13:05 +1100
Re: Explaining names vs variables in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-03 16:09 +0000
Re: Explaining names vs variables in Python Chris Angelico <rosuav@gmail.com> - 2016-03-03 08:52 +1100
Re: Explaining names vs variables in Python Rustom Mody <rustompmody@gmail.com> - 2016-03-02 17:23 -0800
Re: Explaining names vs variables in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-02 22:51 +0000
Re: Explaining names vs variables in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-03 04:10 +1100
Re: Explaining names vs variables in Python Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-03-02 10:08 +0100
Effects of caching frequently used objects, was Re: Explaining names vs variables in Python Peter Otten <__peter__@web.de> - 2016-03-02 10:12 +0100
Re: Explaining names vs variables in Python Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-03-02 11:35 +0200
Re: Explaining names vs variables in Python Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-02 08:13 -0700
Re: Explaining names vs variables in Python Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-03-02 17:37 +0200
Re: Explaining names vs variables in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-02 21:16 +1100
Re: Explaining names vs variables in Python "ast" <nomail@invalid.com> - 2016-03-02 11:52 +0100
Re: Explaining names vs variables in Python Salvatore DI DIO <salvatore.didio@gmail.com> - 2016-03-02 02:58 -0800
Re: Effects of caching frequently used objects, was Re: Explaining names vs variables in Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-03-02 09:16 -0500
Re: Explaining names vs variables in Python Ben Finney <ben+python@benfinney.id.au> - 2016-03-03 04:53 +1100
RE: Effects of caching frequently used objects, was Re: Explaining names vs variables in Python Albert-Jan Roskam <sjeik_appie@hotmail.com> - 2016-03-25 13:03 +0000
Re: Effects of caching frequently used objects, was Re: Explaining names vs variables in Python Chris Angelico <rosuav@gmail.com> - 2016-03-26 00:22 +1100
Re: Effects of caching frequently used objects, was Re: Explaining names vs variables in Python Ethan Furman <ethan@stoneleaf.us> - 2016-03-25 09:45 -0700
csiph-web