import os path="abc.txt" if os.path.isdir(path): print(" It is a directory") elif os.path.isfile(path): print(" It is a normal file") else: print("It is a special file (socket, FIFO, device file)" ) print()