473,513 Members | 2,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

write()

I copied the lines

f=open('/tmp/workfile', 'w')
print f
f.close()

from Python 2.4 Documentation 7.2. But it said IOerror No such file or
directory" '/tmp/workfile'

Is it something about the os? I'm using Python 2.4 under WinXP.
Thanks. Without / I can open it.

Jul 27 '06 #1
7 1847

manuhack wrote:
I copied the lines

f=open('/tmp/workfile', 'w')
print f
f.close()

from Python 2.4 Documentation 7.2. But it said IOerror No such file or
directory" '/tmp/workfile'

Is it something about the os? I'm using Python 2.4 under WinXP.
Thanks. Without / I can open it.

f=open(r'c:\blah\blah').read()

Jul 27 '06 #2
How about write mode? Changing r to w doesn't work...

mi****@optusnet.com.au wrote:
manuhack wrote:
I copied the lines

f=open('/tmp/workfile', 'w')
print f
f.close()

from Python 2.4 Documentation 7.2. But it said IOerror No such file or
directory" '/tmp/workfile'

Is it something about the os? I'm using Python 2.4 under WinXP.
Thanks. Without / I can open it.


f=open(r'c:\blah\blah').read()
Jul 27 '06 #3

manuhack wrote:
How about write mode? Changing r to w doesn't work...

mi****@optusnet.com.au wrote:
manuhack wrote:
I copied the lines
>
f=open('/tmp/workfile', 'w')
print f
f.close()
>
from Python 2.4 Documentation 7.2. But it said IOerror No such file or
directory" '/tmp/workfile'
>
Is it something about the os? I'm using Python 2.4 under WinXP.
Thanks. Without / I can open it.

f=open(r'c:\blah\blah').read()
what is it that you want to do??

in XP if i have or want to create a file in c:\ called test.txt i would
do this:

f = open(r'c:\test.txt', 'w')
f.write("rock the house party")
f.close()

Jul 27 '06 #4
"manuhack" <ma******@gmail.comwrote in news:1153981114.837884.232610
@p79g2000cwp.googlegroups.com:
I copied the lines

f=open('/tmp/workfile', 'w')
print f
f.close()

from Python 2.4 Documentation 7.2. But it said IOerror No such file or
directory" '/tmp/workfile'

Is it something about the os? I'm using Python 2.4 under WinXP.
Thanks. Without / I can open it.
The problem is probably that you don't have a '/tmp' directory. WinXP
doesn't create a directory structure to match a file path specification. If
you first create the '/tmp' directory (which is a directory off the root of
your hard drive on WinXP, so that if your current directory is on a D:
drive it would be D:\tmp), then your code would work.

--
rzed
Jul 27 '06 #5
Then is there any way to create a directory under XP using Python?

Rick Zantow wrote:
"manuhack" <ma******@gmail.comwrote in news:1153981114.837884.232610
@p79g2000cwp.googlegroups.com:
I copied the lines

f=open('/tmp/workfile', 'w')
print f
f.close()

from Python 2.4 Documentation 7.2. But it said IOerror No such file or
directory" '/tmp/workfile'

Is it something about the os? I'm using Python 2.4 under WinXP.
Thanks. Without / I can open it.

The problem is probably that you don't have a '/tmp' directory. WinXP
doesn't create a directory structure to match a file path specification. If
you first create the '/tmp' directory (which is a directory off the root of
your hard drive on WinXP, so that if your current directory is on a D:
drive it would be D:\tmp), then your code would work.

--
rzed
Jul 27 '06 #6
manuhack wrote:
Then is there any way to create a directory under XP using Python?
import os
os.mkdir("C:\\myosisbroken")

--
Dale Strickland-Clark
Riverhall Systems www.riverhall.co.uk

Jul 27 '06 #7

"manuhack" <ma******@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
>I copied the lines

f=open('/tmp/workfile', 'w')
print f
f.close()

from Python 2.4 Documentation 7.2. But it said IOerror No such file or
directory" '/tmp/workfile'

Is it something about the os? I'm using Python 2.4 under WinXP.
Thanks. Without / I can open it.
In addition to what others said, if you need to open a temporary file,
it's better to use os.tmpfile() to get a file descriptor and not to
rely on magic file names like '/tmp/workfile'. So instead of open()
you should do:

import os

f = os.tmpfile()

This should work fine of both Windows and UNIX systems.

Andy.
Jul 30 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2889
by: Greg Hurlman | last post by:
I've got what I'm sure is a very simple problem. In an ASP page, I am trying to write out 4 fields from a recordset in succession: Response.Write rs("LastName") Response.Write rs("Suffix")...
1
2857
by: techy techno | last post by:
Hii Just wanted to know how can I decorate my texboxes and Listmenu which is called from a JS file using the following code below: document.write("<SELECT NAME='cur2' ONCHANGE='cconv1();'>");...
2
2366
by: Brett Baisley | last post by:
Hello I have a block of html code that I want to run by calling a javascript function to print it. Its basically a table with menu items in it that is the same for many pages, and instead of...
0
1739
by: hari krishna | last post by:
hi all, My requirement is to generate xl reports throu Asp.Net without installing xl on web server computer. i am using Response object and wrtifile method as below. i dont know whether it is...
8
17867
by: Ben | last post by:
Hi all, Just wondering how to write (using document.write) to a table cell. I have table with 3 rows and 3 colums. I want to write from within the Javascript to say third column of a first row....
4
2932
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400,...
11
16194
by: Vmusic | last post by:
Hi, I am trying to write out an array of string variables to Notepad. I can't get SendKeys to accept the string variable only literal quoted strings. I DO NOT want the hassle of writing to a...
4
4314
by: cbtechlists | last post by:
I have an ASP app that we've moved from a Windows 2000 to a Windows 2003 server (sql server 2000 to sql server 2005). The job runs fine on the old servers. Part of the app takes a recordset and...
0
5863
by: kuguy | last post by:
Hi all, I'm new to the forums, so I hope this isn't in the wrong place... I have that "Software caused connection abort: socket write error" exception error that i've never meet before. ...
8
7084
by: Mateusz Viste | last post by:
Hi, I am trying make some multimedia files playable from my website. So far, I am able to generate dynamically a new page containing the right <embed> section. However, when I load my script, it...
0
7269
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
7123
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3237
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.