>>>import os
>>>os.path.isdir(fileordirectoryname)
If directory, its output will be True.
If not, it will be False.