Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10613
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: NoneType and new instances |
| Date | 2011-07-30 23:34 -0400 |
| References | <mailman.1575.1311866659.1164.python-list@python.org> <e0a83207-62b7-4078-bedf-322a90907703@w24g2000yqw.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1686.1312083252.1164.python-list@python.org> (permalink) |
On 7/30/2011 12:39 PM, bruno.desthuilliers@gmail.com wrote: > On 28 juil, 17:39, Ethan Furman<et...@stoneleaf.us> wrote: >> >> --> bool(0) is bool(0) >> True > This test is not reliable It is in the sense that it will always work -- because False/True are doubletone constants and so documented. But expr is expr == True does not reliably say it will always be true, because > - a same id can be reused for terms (I have > already seen such things happening). If you want a reliable test, use: > > #> a = bool(0) > #> b = bool(0) > #> a is b > True > > Note that this still fails to prove anything since bool is a subclass > of int and CPython caches "small" integers: > > #> a = 42 > #> b = 42 > #> a is b > True
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
NoneType and new instances Ethan Furman <ethan@stoneleaf.us> - 2011-07-28 08:39 -0700
Re: NoneType and new instances Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> - 2011-07-28 11:34 -0400
Re: NoneType and new instances Ben Finney <ben+python@benfinney.id.au> - 2011-07-29 07:46 +1000
Re: NoneType and new instances Ethan Furman <ethan@stoneleaf.us> - 2011-07-28 15:26 -0700
Re: NoneType and new instances Ben Finney <ben+python@benfinney.id.au> - 2011-07-29 09:52 +1000
Re: NoneType and new instances Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-29 11:16 +1000
Re: NoneType and new instances Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-07-30 14:50 +1200
Re: NoneType and new instances Terry Reedy <tjreedy@udel.edu> - 2011-07-30 09:35 -0400
Re: NoneType and new instances python@bdurham.com - 2011-07-30 11:43 -0400
Re: NoneType and new instances "bruno.desthuilliers@gmail.com" <bruno.desthuilliers@gmail.com> - 2011-07-30 09:39 -0700
Re: NoneType and new instances Terry Reedy <tjreedy@udel.edu> - 2011-07-30 23:34 -0400
Re: NoneType and new instances Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-31 14:28 +1000
csiph-web