move up a level
John Machin
sjmachin at lexicon.net
Tue Nov 21 01:55:07 EST 2006
rplobue at yahoo.com wrote:
> alright, noob question: i want to open a file in a directory above the
> current one i'm in. I'm trying to use myfile =
> open('../thefileiwant.txt', 'r') but the ../ doesn't work. How do i
> do it?
"Doesn't work" means what?
Have you looked at the getcwd and chdir functions in the os module?
You may wish to check that os.getcwd()'s notion of "current directory"
is the same as yours.
If you can't make any progress, ask again; do copy and paste the
relevant parts of your script instead of trying to describe what you
did. Also copy and paste output. Hint: use temporary print statements
to show what is happening.
HTH,
John
More information about the Python-list
mailing list