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) .. : os.remove('test.txt') f = file('test.txt','a+') f.readline()
'' f.write('beep')
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:
f.seek(0) f.write('beep')
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. import os os.remove('test.txt') f = file('test.txt','a+') f.readline()
'' f.write('beep')
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 0 1122 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: David Peach |
last post by:
Hello, hope somebody here can help me... I have a query that lists
defects recorded in a user defined date range. That query is then used
as the source for a Cross Tab query that cross-tabs count...
|
by: Jeff Rodriguez |
last post by:
Here's what I want do:
Have a main daemon which starts up several threads in a Boss-Queue structure.
From those threads, I want them all to sit and watch a queue. Once an entry
goes into the...
|
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: Scott M. |
last post by:
How can I disable the cross-site scripting check for one particular page of
a site?
|
by: Pieter |
last post by:
Hi,
I'm having some weird problem using the BackGroundWorker in an Outlook
(2003) Add-In, with VB.NET 2005:
I'm using the BackGroundWorker to get the info of some mailitems, and after
each item...
|
by: Rob Woodworth |
last post by:
Hi,
I'm having serious problems getting my report to work. I need to
generate a timesheet report which will contain info for one employee between
certain dates (one week's worth of dates). I...
|
by: Bart Van der Donck |
last post by:
Hello,
I'm presenting my new library 'AJAX Cross Domain' - a javascript
extension that allows to perform cross-domain AJAX requests.
http://www.ajax-cross-domain.com/
Any comments or...
|
by: ampo |
last post by:
Hello.
Can anyone help with cross-domain problem?
I have HTML page from server1 that send xmlHTTPRequest to server2.
How can I do it?
Thanks.
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |