[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

invert or not ?

Stef Mientki

3/1/2008 10:47:00 AM

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)

thanks,
Stef
3 Answers

Peter Otten

3/1/2008 11:15:00 AM

0

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

Grant Edwards

3/2/2008 4:12:00 AM

0

On 2008-03-01, Stef Mientki <stef.mientki@gmail.com> 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
visi.com American a 55-year-old
houseboy...

smith.jeff28

4/1/2008 6:09:00 PM

0

On Apr 1, 2:05 am, Roger Larsson <exins...@tiscali.se> wrote:
> On 1 Apr, 04:47, PeaceTrainMakesStopatARS...@gmail.com wrote:
>
> >      Happiness and strength endure only in the absence of hate. To
> > hate alone is the road to disaster. To love is the road to strength.
> > To love in spite of all is the secret of greatness. And may very well
> > be the greatest secret in this universe.
>
> > L. Ron Hubbard
>
> Happiness and strength endure only in the absence of Ron Hubbards con
> scientology.
>
> If critics hated people they wouldn't do a shit to warn people to be
> scientologists.
>
> It's out of love to the people critics warn people to be
> scientologists.