detect if file or dir
Bill Bell
bill-bell at bill-bell.hamilton.on.ca
Wed Jul 11 20:37:27 EDT 2001
pedro at athlet.de (pedro) wrote:
> how can i detect if sth. is a file or a directory? exists(directory)
> does tell me if sth. is a directory but exits my script wenn it hits a
> file.
Pedro,
I assume you mean that the use of 'exists' raises an exception?
Notwithstanding the comments offered by others on this list, I don't
think it should. For example, on my machine:
>>> os.path.exists ( r'c:\temp.txt')
1
ie, it works without raising an exception given a file name.
Bill
More information about the Python-list
mailing list