Как правильно проверить атрибуты доступа файла? То есть доступна ли запись в файл или является ли он исполняемым?
Для этого в 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
#CHZ/USDT analysis :
#CHZ is currently in a downtrend and making new lows. Look for a price retracement to test the resistance zone for a short entry opportunity. Lower levels will be the target level.
TF : 2H
Entry : $0.04862
Target : $0.04200
SL : $0.05193
#CHZ/USDT analysis :
#CHZ is in an uptrend, trading above the 200 EMA. After the breakout of the previous swing high, the price is sustaining above it. The price is anticipated to continue its bullish momentum and rise higher. Wait for a pullback to the support zone for a long entry.
TF : 2H
Entry : $0.0535
Target : $0.0560
SL : $0.0519