Re: Write to a binary file



On Apr 4, 11:40 am, "Thomi Aurel RUAG A" <Aurel.Th...@xxxxxxxx> wrote:
Hy
I'm using Python 2.4.2 on an ARM (PXA-270) platform (linux-2.6.17).
My Goal is to write a list of bytes down to a file (opened in binary
mode) in one cycle. The crux is that a '0x0a' (line feed) will break the
cycle of one writing into several pieces. Writing to a "simple" file,
this wouldn't cause any problem.

Assuming - without questioning ;-) - that a device file (/dev/*) has to
be written in one cycle because one write call will be interpreted as
one "transaction". The write behaviour on line feed's isn't really
usefull because such "transactions" would be broken up into serveral
pieces and therefore for the device into several "transactions".

Is there a possibility to write a list of bytes "en bloc" to a binary
file? (without the interpreting of the line feed's)
Opening a file i binary mode (i.e "wb") seems not to be enough.

Thank you for any help
Aurel

I don't know if these will help or not, but they all have info on
binary file writing:

http://mail.python.org/pipermail/python-list/2001-September/105529.html
http://docs.python.org/tut/node9.html
http://www-128.ibm.com/developerworks/opensource/library/os-python8/

If your data is a bunch of strings, have to tried just concatenating
them into one variable and writing that? If Python is the only program
you will use to read the data, you should be able to pickle it.

Mike

.



Relevant Pages

  • Write to a binary file
    ... I'm using Python 2.4.2 on an ARM platform. ... cycle of one writing into several pieces. ... one "transaction". ...
    (comp.lang.python)
  • Re: Efficiency of using long integers to hold bitmaps
    ... I cannot find information in the Python ... All my recent professional experience is in writing Ada, ... which is not my idea of a rapid prototyping language (or a rapid deliverable ... use, but for NP-complete problems the ceiling is always too low, and one is ...
    (comp.lang.python)
  • Hi reliability files, writing,reading,maintaining
    ... I am writing some web scripts in python to receive small amounts of data ... from remote sensors and store the data in a file. ...
    (comp.lang.python)
  • Hi reliability files, writing,reading and maintaining
    ... I am writing some web scripts in python to receive small amounts of data ... I also assume each server will maintain two copies of the current data file, ...
    (comp.lang.python)
  • Re: Python secure?
    ... Python will result in you writing less lines of code. ... the clipboard, someone typing rapid random junk, input data ... I would advise you to write your first program in Python. ...
    (comp.lang.python)