Check for presence fo directory

Peter Hansen peter at engcorp.com
Fri Sep 24 07:01:42 EDT 2004


Maurice LING wrote:
> 
>> Should we assume you're rejecting os.path.exists() for some reason?
>>
> You can assume Maurice.knowledge(os.path.exists()) to raise an 
> exception. Thanks, I guess os.path.exists() is the one to use.

Make sure you check out its siblings, os.path.isfile() and
os.path.isdir(), as well.  Often it can be important to
make sure you aren't accidentally trying to treat an
*existing* file as a directory.

-Peter



More information about the Python-list mailing list