checking the existence of a fiel

Matthew Schinckel matt at null.net
Wed Jul 12 01:28:16 EDT 2000


On Jul 11, I overheard Fernando Rodríguez mutter:

>     How can I check if a file exists? O:-)

try:
	fp = open(file,'r')
	# code to run if file exists.
except IOError:
	print "File:",file,"Does not exist."

-- 
Matthew Schinckel     <matt at null.net>

What I tell you three times is true.




More information about the Python-list mailing list