invert or not ?

Peter Otten __peter__ at
Sat Mar 1 12:15:22 CET 2008

Stef Mientki 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.
> Is this coincidence ?

[Are cryptical posts contagious? I hope not.]

Please explain what you did in your experiments and what did not work as

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

Do you travel with a suitcase or a lorry? The advantage of import is that
your programs won't grind to a halt loading stuff you don't need most of
the time. By the way

>>> operator.invert(42) == ~42


More information about the Python-list mailing list