[python] how to check if a file is a directory or regular file in python?