[PYTHONMAC-SIG] file modes in Mac Python (frustrating)

Steven D. Majewski sdm7g@Virginia.EDU
Fri, 11 Jul 1997 16:07:29 -0400 (EDT)



When I try to open a file with read and write access using __builtin__
open on MacPython 1.4, I get an error when I try to write:

	 IOError: (0, 'component result = no error')

According to MSL Reference, "rb+", "wb+" modes should work. 
( Or is it using I/O routines from CWGUSI ? )

Using os.open, os.read, os.write, os.lseek seems to work properly
for read and write access to a file. 

( But I've had to look up the hex values of flags from the .h files. 
  These aren't defined in a Mac module anywhere, are they ? )


Module posixfile works somewhat. It import without an error, but
some methods  import and use posix, fcntl, FCNTL which aren't on Mac,
so they will fail. ( For example, you can't create a posixfile and
use flags to change it's mode, because that uses fcntl. Note that
there is an fcntl call in MSL, but it only supports F_DUPFD. )


  Anyone else have any tips on the best, most portable IO methods
in Mac Python ? ( Since the obvious way doesn't seem to work! 
Well -- the lib ref manual *does* say that whether 'r+' et.al.
work is platform dependent. ) 



---|  Steven D. Majewski   (804-982-0831)  <sdm7g@Virginia.EDU>  |---
---|  Department of Molecular Physiology and Biological Physics  |---
---|  University of Virginia             Health Sciences Center  |---
---|  P.O. Box 10011            Charlottesville, VA  22906-0011  |---
All power corrupts and obsolete power corrupts obsoletely." - Ted Nelson


_______________
PYTHONMAC-SIG  - SIG on Python for the Apple Macintosh

send messages to: pythonmac-sig@python.org
administrivia to: pythonmac-sig-request@python.org
_______________