Что-то вы гоните насчет "привычного вида формата 755 и 644". Я вот вообще не понял что это!😳
Действительно, что означают цифры которые мы получили в прошлом посте?
Это кодировка, заключающая в себе режимы доступа к файлу.
Подробней можно почитать в статье про chmod.
Там можно увидеть альтернативное обозначение того же самого с помощью символов r w x, что значит чтение, запись, исполнение.
Чтобы преобразовать восьмеричное число в такое обозначение в Python есть готовая функция
>>> stat.filemode(0o755)
'?rwxr-xr-x'
Мы видим 3 группы по 3 символа, дающие 3 типа доступа для 3 типов юзеров.
А что за знак вопроса в начале?
Давайте передадим в эту функцию необрезанное значение от os.stat
>>> stat.filemode(os.stat(path).st_mode)
'drwxr-xr-x'
Это данные, которые мы безжалостно обрезали в прошлый раз😼
Первый символ обозначает тип объекта. Это может быть файл (-), директория (d) или симлинк (l).
Вот простая схема данной кодировки
[1][3][3][3]
│ │ │ │
│ │ │ └──> Others Permissions
│ │ └─────> Group Permissions
│ └────────> Owner Permissions
└───────────> File Type
(разверните экран если вы с телефона)
Если вы попробуете получить пермишены для симлинка то получите пермишены для файла
>>> path = '.venv/bin/python3'
>>> stat.filemode(os.stat(path).st_mode)
'-rwxr-xr-x'
Чтобы получить свойства именно симлинка, нужно это явно указать
>>> stat.filemode(os.stat(path, follow_symlinks=False).st_mode)
'lrwxrwxrwx'
#tricks#basic
🌎 On Neptune’s largest moon Triton, geysers of nitrogen ice erupt from beneath the surface, shooting plumes up to 8 kilometers high into the tenuous atmosphere. These cryovolcanic eruptions are driven by sunlight warming a thin layer of transparent ice, a unique phenomenon that shapes Triton's mysterious, dark-streaked terrain. ✨
#Triton⚡#cryovolcanism⚡#Neptune
👉subscribe Universe Mysteries
🪐 On Triton, Neptune's largest moon, icy volcanoes known as cryovolcanoes have been observed erupting plumes of nitrogen gas many kilometers high. This frigid world’s surface is scattered with dark streaks—evidence of these geysers venting from below, hinting at surprising geologic activity beneath its frozen crust. ✨
#Triton⚡#cryovolcanoes⚡#Neptune
👉subscribe Universe Mysteries
🪐 On Neptune’s moon Triton, geysers erupt through its icy crust, blasting nitrogen gas more than 8 kilometers above the surface. These plumes create dark streaks and ever-changing patterns on Triton's frozen landscape, transforming the distant moon into one of the most dynamic worlds in the outer solar system. ✨
#Triton⚡#geysers⚡#Neptune
👉subscribe Universe Mysteries
🪐 Within our solar system, scientists have discovered that the subsurface ocean of Neptune’s moon, Triton, could provide the right conditions for life despite its bitterly cold surface. Tidal forces, or gravitational stretching from Neptune, may keep this hidden ocean liquid beneath Triton’s icy shell, making it a fascinating target in the ongoing search for places where life could exist beyond Earth. ✨
#Triton⚡#ocean⚡#astrobiology⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 Neptune’s largest moon, Triton, is thought to conceal a hidden ocean beneath its frozen exterior, thanks to heat generated by radioactive decay in its rocky core. Despite surface temperatures near minus 235°C, this internal heat may keep water liquid deep inside, making Triton one of the most intriguing ocean worlds in the outer solar system. ✨
#Triton⚡#oceanwonder⚡#Neptune⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels