On Wed, Nov 28, 2007 at 09:07:56PM +0100, Gianmaria Iaculo - NVENTA wrote
regarding Bit Operations:
>
> Hi there,
> I'm so new to python (coming from .net so excuse me for the stupid question)
> and i'm tring to do a very simple thing,with bytes.
>
> My problem is this:
>
> i've a byte that naturally is composed from 2 nibbles hi&low, and two
> chars.. like A nd B. What i wonna do is to write A to the High nibble and B
> to the the lower nibble.
> Or an other example can be i've 2 numbers.. like 7 and 8 and whant to do the
> same as for chars.
>
> I'm really confused on how t do it, maybe cause python is type-less (dynamic
> typed)
>
Do you possibly mean that your letters are hexadecimal digits? If so, you can
follow the advice given to you by others for numbers, treating your letters as
numbers:
A=10
B=11
...
F=15
py>>> hex(15)
'0xf'
>>> int('f', 16)
15
>>> int('0xf', 16)
15
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list