how to check if a file is a directory or regular file in python? [duplicate] September 21, 2022 by Tarik os.path.isfile("bob.txt") # Does bob.txt exist? Is it a file, or a directory? os.path.isdir("bob")