using st_mode to identify file or directory

paramiko, python, stat

Solution

Yes, the stat structure `st_mode` does contain that information.

Use the `stat` module to determine if it is a directory:

import stat

if stat.S_ISDIR(lstat_result.st_mode):

Problem

is there any way to identify whether an object is file or directory using st_mode value? I'm using paramiko lstat() to retrieve the st_mode information from sftp files.

Original source