You need to pass a filename string to open
. There's an extra complication when the string has \
in it, because that's a special string escape character to Python. You can fix this by doubling up each as \\
or by putting a r
in front of the string as follows: r'C:\name\MyDocuments\numbers'
.
Edit: The edits to the question make it completely different from the original, and since none of them was from the original poster I'm not sure they're warrented. However it does point out one obvious thing that might have been overlooked, and that's how to add "My Documents" to a filename.
In an English version of Windows XP, My Documents
is actually C:\Documents and Settings\name\My Documents
. This means the open
call should look like:
open(r"C:\Documents and Settings\name\My Documents\numbers", 'r')
I presume you're using XP because you call it My Documents
- it changed in Vista and Windows 7. I don't know if there's an easy way to look this up automatically in Python.