473,405 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

chdir()


Tried executing os.chdir("c:\twill") from a python Tk shell and got
the error message:

WindowsError: [Error 123] The filename, directory name, or volume
label syntax is incorrect: 'c:\twill'.

I have the directory exists as I copied the name from the explorer
window that was open to it.

What is wrong with the syntax?

thanks,

jh

May 8 '07 #1
5 10501
HMS Surprise napisał(a):
Tried executing os.chdir("c:\twill") from a python Tk shell and got
the error message:

WindowsError: [Error 123] The filename, directory name, or volume
label syntax is incorrect: 'c:\twill'.

I have the directory exists as I copied the name from the explorer
window that was open to it.

What is wrong with the syntax?
Unescaped '\' character. Try with raw string (r"c:\twill") or escape it
("c:\\twill").

--
Jarek Zgoda
http://jpa.berlios.de/
May 8 '07 #2
On May 8, 3:54 pm, HMS Surprise <j...@datavoiceint.comwrote:
Tried executing os.chdir("c:\twill") from a python Tk shell and got
the error message:

WindowsError: [Error 123] The filename, directory name, or volume
label syntax is incorrect: 'c:\twill'.

I have the directory exists as I copied the name from the explorer
window that was open to it.

What is wrong with the syntax?

thanks,

jh

Use
os.chdir(r"c:\twill")
instead.

The "\t" character is the escape character for a tab. You can avoid
such a faux pas by using the raw string construct of the form r"some
string". Otherwise, any backslashes in in your string will be
interpreted as escape characters.

-Basilisk96

May 8 '07 #3
On Tuesday 08 May 2007 22:54:39 HMS Surprise wrote:
WindowsError: [Error 123] The filename, directory name, or volume
label syntax is incorrect: 'c:\twill'.

What is wrong with the syntax?
Try 'c:\\twill' because the '\' character is the escape character.
Eg: \n is new-line (aka crlf)
\t is tab etc.

To understand how these work, try this:

print 'hello\nworld'

and you get:

hello
world

May 8 '07 #4
On Tue, 2007-05-08 at 12:54 -0700, HMS Surprise wrote:
Tried executing os.chdir("c:\twill") from a python Tk shell and got
the error message:

WindowsError: [Error 123] The filename, directory name, or volume
label syntax is incorrect: 'c:\twill'.
Backslash-t is a tab character, so you're trying to chdir to
C:<tab>will, which is not a valid path name. Use a forward slash, double
up the backslash, or use a raw string literal:

os.chdir("c:/twill")
os.chdir("c:\\twill")
os.chdir(r"c:\twill")

HTH,

--
Carsten Haese
http://informixdb.sourceforge.net
May 8 '07 #5
On May 8, 3:06 pm, Carsten Haese <cars...@uniqsys.comwrote:
On Tue, 2007-05-08 at 12:54 -0700, HMS Surprise wrote:
Tried executing os.chdir("c:\twill") from a python Tk shell and got
the error message:
WindowsError: [Error 123] The filename, directory name, or volume
label syntax is incorrect: 'c:\twill'.

Backslash-t is a tab character, so you're trying to chdir to
C:<tab>will, which is not a valid path name. Use a forward slash, double
up the backslash, or use a raw string literal:

os.chdir("c:/twill")
os.chdir("c:\\twill")
os.chdir(r"c:\twill")

HTH,

--
Carsten Haesehttp://informixdb.sourceforge.net
Thanks all. Windows bytes me again. I know better just wasn't
thinking. \n

May 8 '07 #6

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

Similar topics

0
by: Andrew Crowe | last post by:
Hi guys, We're using the ISAPI version of PHP with IIS5.0 On some websites for some reason any php file in the websites root is given the path winnt/system32 (getcwd() returns...
5
by: Nicholas Geraldi | last post by:
I have a script that uses the chdir() function. I know the script works ( works perfectly on my host ), but when I put the script on my server here at work I get the following error. Warning:...
0
by: Jon Schull | last post by:
I find that cgitb fails to show error context if I've changed my default directory, so I tried to subclass cgitb and get it to save the directory we were in when the program started. Didn't work. ...
4
by: Yun Mao | last post by:
Hi, How to make changes to os.environ and os.path.chdir still effective after I run the script? Currently, the changes are only good within my script. I would like the shell who called python...
0
by: Tom McDavid | last post by:
I'm trying to learn more Python and have come across a strange behavior. I have Python2.3 installed on a Win2K machine. If I start the python command line, I can do the following: Python 2.3.2...
11
by: Chris | last post by:
Hi, For info I am using VS 2005 beta 2 I have a Console App and I want it to do the equivalent of a Change Directory (CD) command that you would do in normal command line mode as follows: ...
3
by: dannycolligan | last post by:
I have a strange problem with os.chdir... here is my script that I am using to edit the filenames of my music library: #!/usr/bin/python from os import * ...
0
by: Julien Biezemans | last post by:
Hi everyone, I've written a file:// scheme stream wrapper that acts like chroot() (but is more flexible, does not require root privileges and works on any platform). Everything works just fine...
4
by: rdoneil | last post by:
I am in unix and in my perl program, I am trying to move back to the directory the program was originally started in. Obviously, at somepoint in my program it has to move to another directory, and...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.