Python about file I/O
Michael Janssen
Janssen at rz.uni-frankfurt.de
Sun Sep 22 07:02:41 EDT 2002
Ken wrote:
> Hi, I have 2 questions on IO, not necessary related to one another:
>
> 1.) How do you list the filenames within a given directory so user can
> choose which file to open?
>
> 2.) How do you ensure the program doesn't crash if I specify a
> filename to open but the file doesn't exist? (I.E. how to check if
> file exist before opening the file?)
>
> Thanks
existence-check is:
os.access(file,os.F_OK)
Michael
More information about the Python-list
mailing list