You can check if a file is a directory or a file using the os.path.isfile method:
Example
>>> import os >>> print os.path.isfile('my_file.txt') True >>> print os.path.isfile('my_folder') False
You can check if a file is a directory or a file using the os.path.isfile method:
>>> import os >>> print os.path.isfile('my_file.txt') True >>> print os.path.isfile('my_folder') False