bitwise not - not what I expected

Carl Banks imbosol at
Mon Aug 18 00:08:15 CEST 2003

Elaine Jackson wrote:
> <snip>
> | Python can't *guess* how many bits you want to keep.
> ** But it could if someone had told it that the leftmost nonzero
> digit is the place to start. I just assumed somebody had told it
> that.

And if someone had done that, it would violate the invariant:

~(~x) == x

In fact, by repeatedly applying ~ you'd eventually zero all the bits.

CARL BANKS         
"You don't run Microsoft Windows.  Microsoft Windows runs you."

More information about the Python-list mailing list