invert or not ?

Peter Otten __peter__ at web.de
Sat Mar 1 06:15:22 EST 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
expected.

> (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
True

Peter



More information about the Python-list mailing list