On 7/30/2011 12:39 PM, bruno.desthuilli...@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
--
http://mail.python.org/mailman/listinfo/python-list