473,486 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

File call error message (double backslash)

Hi
I am writing on an application, that is supposed to read a file into a
single string:
My program though, when I run it, gives me an error, that the called
file is non existent
'C:\ \Documents and Settings\ \Fred\ \My Documents\ \School\ \Bio'
Is it normal that python adds the space and extra backslash? Because
if I print the path of the called file before the open command, it
normally prints it with only one backslash.
Is there any possiblity of surpressing this?
I am using Python 2.3.5 with Pywin built 163 on Windows.
Thanks for all help
Jul 18 '05 #1
2 2436
Hello Fred,
Backslashes are used as an escape and not just in Python ( consider
'\r\n' )
To use a backslash you must escape it with two of them like this: \\
'c:\\windows\\dir'
or you can use a raw string:
r"c:\windows\dir"
or you can use forward slashes. Yes that works ;)
"c:/windows/dir"

Windows uses '\' as a path sep but it also understands '/'.
*nix uses '/' as a path sep.

hth,
M.E.Farmer

Jul 18 '05 #2

Fred wrote:
Hi
I am writing on an application, that is supposed to read a file into a single string:
My program though, when I run it, gives me an error, that the called
file is non existent
'C:\ \Documents and Settings\ \Fred\ \My Documents\ \School\ \Bio'
Is it normal that python adds the space and extra backslash? Because
if I print the path of the called file before the open command, it
normally prints it with only one backslash.


The space between the \ \ is NOT normal. Please post the exact (copy
and past!) text of the trace-back and error message.

Jul 18 '05 #3

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

Similar topics

6
1833
by: Hans Stoessel | last post by:
Hi I have a C application on a Windows PC who shoul delete files on a Sun which is in the same network. I try this with the 'remove' command, e.g. remove(\\Sun\Temp\File.jpg). But this doesn't...
23
2612
by: Francesco Zavatarelli | last post by:
I downloaded a free c-compiler and I'm trying to access a file in a windows directory c:\program files\... but I get an error when I run the code. Probably my declaration char* NAME is wrong....
9
4305
by: steph_de_marseille | last post by:
I would like to write a x array in a file. If the array has a small numbers of columns I know I can use a loop like: int i,j; double array; FILE *file1; file1=fopen("data.dat","w");...
13
39830
by: Chris Johnson | last post by:
I have what seems to be such a simple thing yet I cannot figure out how to do it. I am using a streamwriter to build a text file. At the end of the process I want to open that same text file in...
6
3672
by: mardif | last post by:
Hi guys. I've a very big big big problem: I've in my windows computer a file named cicciobello.html, located in c:\documents and settings\username\desktop\cicciobello.html. Now, I MUST open...
10
3941
by: Julia | last post by:
Hi, there, I am trying to append a binary file by using: FILE *strean; stream = fopen( "c:\temp.dat", "ba+" )); Is there a way that I can check if the file exists or not before fopen,...
1
63981
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
34
5294
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
3
5113
by: =?Utf-8?B?R2FuZXNoYQ==?= | last post by:
Hi I would like to use File.Copy with UNC paths. I have seen this problem reported by others as well. Can i use File.Copy with UNC paths. ie., i would like to copy a file from one of the folder to...
0
7099
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,...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6842
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
7319
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
4864
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
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3069
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...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.