NoneType and new instances
bruno.desthuilliers at gmail.com
bruno.desthuilliers at gmail.com
Sat Jul 30 12:39:24 EDT 2011
On 28 juil, 17:39, Ethan Furman <et... at stoneleaf.us> wrote:
>
> --> bool(0) is bool(0)
> True
>
This test is not reliable - 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
More information about the Python-list
mailing list