Как правильно проверить атрибуты доступа файла? То есть доступна ли запись в файл или является ли он исполняемым?
Для этого в Python есть функция os.access()
Проверять так:
os.access(path, flag)
Функция вернёт bool в зависимости от наличия указанного флага.
Всего есть 4 флага проверки:
os.F_OK - наличие файла на диске
os.R_OK - доступ на чтение
os.W_OK - доступ на запись
os.X_OK - доступ на исполнение
Например, вместо try-except лучше делать так (пример из документации):
if os.access("myfile", os.R_OK):
with open("myfile") as fp:
return fp.read()
#basic#libs
Hi, any crystal lovers here?
I'm rehoming @ reselling some of my crystal bracelets collection at a very much affordable price for its quality 🥰
Click link to view:
https://www.instagram.com/p/CE9b7FnMBag/?igshid=15fs2s08ixmug
Note:
🌸 Green Phantom & Red Healer Quartz sold.🌸🥰
Still available:
🌹 Aquamarine RM18
🌹 Rhodochrosite RM78
🌹 Tourmaline RM108
🌹 Howlite RM48
Check out the link to read more on the benefits of each living crystal😍
#crystallovers#marrdiimarykay@quietworld🍃
Have you ever heard of Memory Palace Technique? – a technique in studying that helps you remember what you learn better and faster?
Well, I'm using that technique, but not in studying; but in reminding myself of gratitude and encouraging positive self affirmation with crystals.
One thing for sure, ever since I get myself involved in crystals (since July to be precised), I'm coping with my self-esteem, motivation & anxiety, better.
Interested? Check out Ponderlog for more 😘
#ponderlog#crystallovers#grootcrystal#meditation#selfhealing#crystalhealing#crystalmeditation#memory#reminder#mindbodyspirit