int('\x23') != 0x23 (a.k.a convert char to integer of its byte representation)

2007-09-15 Thread Boris Dušek
Hi, I am looking for the best way to convert a string of length 1 (= 1 character as string) to integer that has the same value as numeric representation of that character. Background: I am writing functions abstracting endianness, e.g. converting a string of length 4 to the appropriate integer

Re: int('\x23') != 0x23 (a.k.a convert char to integer of its byte representation)

2007-09-15 Thread Marc 'BlackJack' Rintsch
On Sat, 15 Sep 2007 11:55:28 +, Boris Dušek wrote: I am looking for the best way to convert a string of length 1 (= 1 character as string) to integer that has the same value as numeric representation of that character. Background: I am writing functions abstracting endianness, e.g.

Re: int('\x23') != 0x23 (a.k.a convert char to integer of its byte representation)

2007-09-15 Thread Boris Dušek
On Sep 15, 1:59 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: So you are looking for the `struct` module in the standard library instead of doing this yourself. :-) If you insist on doing it yourself take a look at the built-in `ord()` function. Thanks Marc, both things are

Re: int('\x23') != 0x23 (a.k.a convert char to integer of its byte representation)

2007-09-15 Thread John Machin
On Sep 15, 9:55 pm, Boris Dušek [EMAIL PROTECTED] wrote: Hi, I am looking for the best way to convert a string of length 1 (= 1 character as string) to integer that has the same value as numeric representation of that character. Background: I am writing functions abstracting endianness, e.g.