by-passing exception [Q]

Bruno Mattarollo brunomadv at ciudad.com.ar
Sun Apr 11 00:54:44 EDT 1999


Hi All Python Gurus ...

	Perhaps this is a stupid question, but it's saturday and it's almost 2AM,
so you may understand my state-of-mind :-)

	I have a script that has to check a directory for the existence of a file,
so I do a os.stat(path-to-file) ... But I want to continue processing even
if this file doesn't exist, so I tryed this:

	try:
		os.stat(path-to-file)
	except IOError, msg:
		blah blah ....

	But I get an exception ... and it doesn't go into the except statement...
Should I be doing a os.listdir(path-to-dir-where-file-resides) and checking
there?

	I am a little bit confused ... Perhaps it's time to go to bed or to stop
drinking beer while working ... :-)

	TIA

/B

Bruno Mattarollo <bruno at gaiasur.com.ar>
... proud to be a PSA member <http://www.python.org/psa>





More information about the Python-list mailing list