hex int and string
Ben Finney
ben+python at benfinney.id.au
Fri Nov 27 04:47:59 EST 2009
(Please don't top-post; it makes the message difficult to follow.
Instead, post inline to the quoted material you're responding to, and
remove material that you're not responding to.)
luca72 <lucaberto at libero.it> writes:
> i'm using pyscard
I don't know what that is; can you give a link to what you're referring
to?
> and for send a command he need a list like this:
>
> cmd = [0xdd,0xff, etc]
Is that Python code? If it is, I've already demonstrated that ‘0xDD’ in
Python code *is* ‘221’. They're different representations that compile
to exactly the same object.
> the problem is that i get a text
> like dd
> and i need to trasform it in 0xdd for the list
Right, which you can do by creating an integer as you've already done:
>>> foo = 'DD'
>>> int(foo, 16)
221
because that *is* the number ‘0xDD’:
>>> int(foo, 16) == 0xDD
True
> and if i use hex i have a sting that is not what i need
So don't do that; use the integer.
--
\ “If you ever reach total enlightenment while you're drinking a |
`\ beer, I bet it makes beer shoot out your nose.” —Jack Handey |
_o__) |
Ben Finney
More information about the Python-list
mailing list