trouble converting c++ bitshift to python equivalent
Grant Edwards
grante at visi.com
Thu May 24 17:01:06 EDT 2007
On 2007-05-24, nanodust at gmail.com <nanodust at gmail.com> wrote:
>> You should really use the struct module for that type of conversion, but
>> you also need to know that indexing of lists and tuples starts at 0, not 1.
>
> indeed, i used to have temp = unpack('h', tBuf[1,3])
Which probably should have been
temp = unpack('h', tBuf[1:3])[0]
But that still doesn't do the same thing as your example which
only used 7 bits from each byte.
> but it was a hack (and as such a bit off ;) as i was having
> troubles casting
Python doesn't have "casting".
--
Grant Edwards grante Yow! A can of ASPARAGUS,
at 73 pigeons, some LIVE ammo,
visi.com and a FROZEN DAQUIRI!!
More information about the Python-list
mailing list