invert or not ?
Steve Holden
steve at holdenweb.com
Sat Mar 1 08:40:54 EST 2008
Stef Mientki wrote:
> hello,
>
> 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.
> Is this coincidence ?
>
> (The disadvantage of invert is that I've to import operators)
>
Bitwise inversion is performed by the "~" operator. I think your
experimentation has been inadequate:
>>> for i in range(-10000, 10000):
... if (not i) == (~i):
... print i
...
-1
>>>
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list