Как правильно проверить атрибуты доступа файла? То есть доступна ли запись в файл или является ли он исполняемым?
Для этого в 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
#ROSE/USDT analysis :
#ROSE is in an uptrend, forming higher highs and higher lows above the 200ema. The price is expected to sustain its bullish momentum and test new highs. Wait for a price retracement over the support zone for a long entry.
TF : 2h
Entry : $0.0606
Target : $0.0696
SL : $0.0561
#ROSE +%33 in just 5 days 🤑🤑
Legs Trading Hub VIP members are just enjoying their profits 🍹
We are crafting our signals by the power of CoinLegs algorithms.
Why don't you chime in and say hello? ⤵️
https://discord.com/invite/8RKtAA9cxZ