Re: Retrieving int from hex in a file.

2008-04-28 Thread Grant Edwards
On 2008-04-28, Filipe Teixeira <[EMAIL PROTECTED]> wrote: > Hi. > > I have to open a binary file from an old computer and recover the > information stored (or at least try to). I use: > > f=open('file.bin','rb') > a=f.read() > f.close() > > a in now a string full of hex representations in the form:

Re: Retrieving int from hex in a file.

2008-04-28 Thread Filipe Teixeira
> > Use ord(q) > > py> help(ord) > Help on built-in function ord in module __builtin__: > > ord(...) > ord(c) -> integer > > Return the integer ordinal of a one-character string. > > py> > > -- > Gabriel Genellina Thank you Gabriel. It fit's my purpose. -- http://mail.python.org/mailman

Re: Retrieving int from hex in a file.

2008-04-28 Thread bgeddy
Filipe Teixeira wrote: Hi. I have to open a binary file from an old computer and recover the information stored (or at least try to). I use: f=open('file.bin','rb') a=f.read() f.close() a in now a string full of hex representations in the form: a[6]='\x14' a[7]='\x20' I would like to convert

Re: Retrieving int from hex in a file.

2008-04-28 Thread Peter Otten
Filipe Teixeira wrote: > I have to open a binary file from an old computer and recover the > information stored (or at least try to). I use: > I would like to convert these hex representations to int, but this If you want to do it efficiently have a look at the array module: >>> import os, arra

Re: Retrieving int from hex in a file.

2008-04-28 Thread Gabriel Genellina
En Mon, 28 Apr 2008 07:14:51 -0300, Filipe Teixeira <[EMAIL PROTECTED]> escribió: > a in now a string full of hex representations in the form: > > a[6]='\x14' > a[7]='\x20' > > I would like to convert these hex representations to int, but this > (the most obvious way) doesn't seem to be working >

Retrieving int from hex in a file.

2008-04-28 Thread Filipe Teixeira
Hi. I have to open a binary file from an old computer and recover the information stored (or at least try to). I use: f=open('file.bin','rb') a=f.read() f.close() a in now a string full of hex representations in the form: a[6]='\x14' a[7]='\x20' I would like to convert these hex representation