File-writing not working in Windows?

jay graves jaywgraves at gmail.com
Fri Jun 6 11:35:32 EDT 2008


On Jun 6, 10:18 am, tda... at gmail.com wrote:
<snippage>
> This code works PERFECTLY in Linux.  Where I have a match in the file
> I'm processing, it gets cut out from the start of the match until the
> end of the match, and written to the temporary file in tempdir.
> It does not work in Windows.  It does not create or write to the
> temporary file AT ALL.  It creates the tempdir directory with no
> problem.

In general, I don't use string concatenation when building paths.
Especially on scripts that are meant to run on multiple platforms.


> Here's the kicker: it works perfectly in Windows if Windows is running
> in VMware on a Linux host!  (I assume that that's because VMware is
> passing some call to the host.)

probably a red herring.

> Can anyone tell me what it is that I'm missing which would prevent the
> file from being created on Windows natively?

Get rid of the 'posix' check and use os.path.join to create
'tempfileName' and see if it works.

HTH.
...
Jay Graves



More information about the Python-list mailing list