if not os.access(pathName, os.F_OK):
if not os.path.exists(pathName):
Better to just catch the exception rather than try to prevent it. There are a zillion reasons that makedirs can fail
def CreateDirectory(pathName): try: os.makedirs(pathName) except OSError, e: # could be that the directory already exists # could be permission error # could be file system is full # look at e.errno to determine what went wrong
To answer your question,
os.access can test for permission to read or write the file (as the logged in user).
os.path.exists simply tells you whether there is something there or not. I expect most people would use
os.path.exists to test for the existence of a file as it is easier to remember.