[Tutor] File path
Kirk Bailey
idiot1@netzero.net
Mon Jun 9 12:37:01 2003
When it is in the current working directory (cwd), you don't. Just open the file.
When it is someplace else, it is pretty safe to declare the complete path.
f1=open('c:\my documents\foobot\foobot.config','r')
SOME operations permit relative addessing, but your milage may vary.
if os.exists('./lists/mylist'):
do.something('yes')
else:
do.something('no')
When it is in the cwd you do not declare a path at all:
f1=open('history.txt','r')
absolute addressing is safe and dependable. Odd that SOME functions allow relative
addressing, and some don't.
Homer Ellison wrote:
> Hello,
>
> I'm new to programming in Python (and to object-oriented programming in
> general). The programming experience I have is from a long time ago, so
> I'm going to have many questions.
>
> How do I specify the file path within my code to access files for
> reading and writing? I'm using a PC with 32-bit Windows.
>
> Thank you,
> Homer
>
--
end
Cheers!
Kirk D Bailey
think
http://www.howlermonkey.net/ +-----+ http://www.tinylist.org/
http://www.listville.net/ | BOX | http://www.sacredelectron.org/
+-----+
"Thou art free"-ERIS think 'Got a light?'-Promethieus
.