Longint?!

I

Ivo

Pythoneers,
I am trying to reed a long integer (4 byte value like in pascal) in python
but i don't seem to succeed.

It's from a binary file where from a certain offset in the file 4 bytes
(longint) tell how long a header is.

because I don't have to assign a type to a variable I don't know how to
ensure i get the longint type read from the file.

Help very much appreciatend.

--
Cheerz,
Ivo.
http://IvoNet.nl


============================
 
D

Dominic

Ivo said:
Pythoneers,
I am trying to reed a long integer (4 byte value like in pascal) in python
but i don't seem to succeed.

It's from a binary file where from a certain offset in the file 4 bytes
(longint) tell how long a header is.

because I don't have to assign a type to a variable I don't know how to
ensure i get the longint type read from the file.

Help very much appreciatend.
maybe the module struct will help you....
 
H

Helmut Jarausch

Ivo said:
Pythoneers,
I am trying to reed a long integer (4 byte value like in pascal) in python
but i don't seem to succeed.

It's from a binary file where from a certain offset in the file 4 bytes
(longint) tell how long a header is.

because I don't have to assign a type to a variable I don't know how to
ensure i get the longint type read from the file.

Help very much appreciatend.

There is an sscanf module around (1995 Stichting Mathematisch Centrum)
which has a 'long' format control.
If you can't find it, I can send you the file.

--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
 
L

Larry Bates

You must read it as binary and use struct.unpack() to convert
to long integer.

HTH,
Larry Bates
Syscon, Inc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,665
Latest member
salkete

Latest Threads

Top