[Tutor] absolute locations

Christopher Spears cspears2002 at yahoo.com
Thu Jan 8 15:22:52 EST 2004


I'm trying to open up a file with the following
absloute path in Windows 2000:

C:\Documents and Settings\Christstopher Spears\My

So I enter the following in IDLE:

>>> import os
>>> fileName = os.path.join("c:", "Documents and
Settings", "Christopher Spears", "My Documents",
"python", "unit4.txt")
>>> fileobject = open(fileName, 'r')

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in -toplevel-
    fileobject = open(fileName, 'r')
IOError: [Errno 2] No such file or directory:
'c:Documents and Settings\\Christopher Spears\\My

I know unit4.txt is there, but I can't seem to
convince python of that!  What is up with \\ anyway?

"I'm the last person to pretend that I'm a radio.  I'd rather go out and be a color television set."
-David Bowie

"Who dares wins"
-British military motto

"Far more creativity, today, goes into the marketing of products than into the products themselves..."
-"Pattern Recognition" by William Gibson

More information about the Tutor mailing list