Как правильно проверить атрибуты доступа файла? То есть доступна ли запись в файл или является ли он исполняемым?
Для этого в 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
#AUCTION/USDT analysis :
#AUCTION has tested the 200 EMA and rebounded from it. The price has broken out of the trendline, confirming the continuation of the bullish trend. The price is anticipated to test the swing high level.
TF : 30min
Entry : $33.35
Target : $37.30
SL : $30.98
#AUCTION/USDT analysis :
#AUCTION is in an uptrend, forming higher highs (HHs) and higher lows (HLs). The price has recently broken out of the trendline, indicating a potential resumption of its bullish momentum. It is anticipated that the price will continue to rise and test previous highs.
TF : 30min
Entry : $20.05
Target : $21.53
SL : $19.06