User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 397,780 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,444 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:

Setting directory for opening files

Join Date: Aug 2005
Location: England - York
Posts: 136
Reputation: a1eio is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 9
a1eio's Avatar
a1eio a1eio is offline Offline
Junior Poster

Re: Setting directory for opening files

  #4  
Jan 1st, 2007
Hmm that's odd.

A single '.' represents the current working path. So you should in theory use that, e.g:
f = file("./SubFolder/test.txt", "r")
f.read()
the above code would open a file called test.txt in the SubFolder, which would be located in the same folder as the 'current working directory' (which SHOULD be where the script is).
So the full path for test.txt could be something like:

"Python/SubFolder/"

But I'm not sure why the previous example didn't work.
Anyway, try using a . in your path, that may work.

hope that helps
alex

P.S
By the way, a single dot (.) means the current folder,
a double dot (..) would go back one folder so you could use "../../" to go back two folders.

EDIT:
One more thing, http://www.bembry.org/technology/pyt.../lesson_12.php
has some pretty good info basic file/folder manipulation.
Last edited by a1eio : Jan 1st, 2007 at 7:34 pm. Reason: adding a useful link
Reply With Quote  
All times are GMT -4. The time now is 4:48 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC