invert or not ?

Grant Edwards grante at
Sun Mar 2 05:12:19 CET 2008

On 2008-03-01, Stef Mientki <stef.mientki at> wrote:

> from the manual I read that a bitwise inversion should be done
> by invert. But from some experiments I see that not works
> equally well.

What experiments are those?

>>> print ~0xaa, not 0xaa
-171 False
>>> print ~0x55, not 0x55
-86 False
>>> print ~True, not True
-2 False

> Is this coincidence ?

Is what coincidence?

> (The disadvantage of invert is that I've to import operators)

No you don't.

Grant Edwards                   grante             Yow!  If elected, Zippy
                                  at               pledges to each and every
                                 American a 55-year-old

More information about the Python-list mailing list