trouble converting c++ bitshift to python equivalent

Grant Edwards grante at visi.com
Thu May 24 16:28:25 EDT 2007


On 2007-05-24, nanodust at gmail.com <nanodust at gmail.com> wrote:
> hello all
>
> i am relatively new to python, catching on, but getting stuck on
> simple thing:
>
> i have two string bytes i need to push into a single (short) int, like
> so in c:
>
>    temp = strBuf[2];
>
>    temp = (temp<<7)+(strBuf[1]);

  (ord(strBuf[2])<<7) + ord(strBuf[1])

-- 
Grant Edwards                   grante             Yow! This PORCUPINE knows
                                  at               his ZIPCODE ... And he has
                               visi.com            "VISA"!!



More information about the Python-list mailing list