If you run os.stat(path)
on a file and then take its st_mode
parameter, how do you get from there to a string like this: rw-r--r--
as known from the Unix world?
Since Python 3.3 you could use stat.filemode
:
In [7]: import os, stat
In [8]: print(stat.filemode(os.stat('/home/soon/foo').st_mode))
-rw-r--r--
In [9]: ls -l ~/foo
-rw-r--r-- 1 soon users 0 Jul 23 18:15 /home/soon/foo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With