invert or not ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stef Mientki

    #1

    invert or not ?

    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
  • Peter Otten

    #2
    Re: invert or not ?

    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.inve rt(42) == ~42
    True

    Peter

    Comment

    • Grant Edwards

      #3
      Re: invert or not ?

      On 2008-03-01, Stef Mientki <stef.mientki@g mail.comwrote:
      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...

      Comment

      Working...