Using st_mode to identify a file or directory

Is there a way to determine if an object is a file or directory using the st_mode value? I am using paramiko lstat () to extract st_mode information from sftp files.

+2
source share
1 answer

Yes, the stat structure st_mode contains this information.

Use the stat module to determine if this is a directory:

 import stat if stat.S_ISDIR(lstat_result.st_mode): 
+2
source

Source: https://habr.com/ru/post/951617/


All Articles