check if dir exists

Abe Frohnman usenetNO at SPAMexperimentzero.org
Wed Jul 9 15:29:35 EDT 2003


Geiregat Jonas wrote:

> How can I check if a dir exists ?

The os.path library has just what you're looking for. Use 
os.path.exists, like so:


#!/usr/bin/python

import os.path

pathToFind = "/usr/bin/local"

if os.path.exists(pathToFind):
         print "Path exists."
else:
         print "Path does not exist."


~AF





More information about the Python-list mailing list