Cross-platform issues with file's a+ mode

  • Thread starter Michael George Lerner
  • Start date
M

Michael George Lerner

I was helping someone debug his code today .. it worked fine on Linux, but
gave a strange error message on Windows. Here's the snippet that goes
wrong in Python 2.2 under Windows (it also happens under 2.3a1 under
Windows and Enthought's 2.3.3, so I think it's pretty generic) .. :
Traceback (most recent call last):
File "<pyshell#48>", line 1, in ?
f.write('beep')
IOError: (0, 'Error')

but .. I can make things work by seeking:

I don't know whether it's important or not, but if I do an f.tell() after
the readline(), it says 0L, which seems reasonable.

For comparison (and this is also true under, e.g., Linux 2.3a1),

bash-2.04$ python
Python 2.2 (#1, Feb 18 2002, 14:48:51) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
What's going on here? Should I expect this behavior? I've never needed
to use a+ mode before .. is it just known to be funny or have interesting
cross-platform issues?

Thanks,

-michael
 

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
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top