Как правильно проверить атрибуты доступа файла? То есть доступна ли запись в файл или является ли он исполняемым?
Для этого в 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
🔔🔔$BUSD supply dropped to 13.7B, from 16B before @PaxosGlobal stopped issuing $BUSD :
- 512M was burnt in the past 15 hours and 1.1B the day before.
- Address holders reduced from 180K to 176K
- @justinsuntron withdrew 300M $BUSD from #Binance to #Paxos to redeem for fiat yesterday.
👉 More details: https://twitter.com/spotonchain/status/1626365035357544448
#Celsius Network transferred 459,561 $ETH ($1.02B) to several CEX in the past 8 hours, including:
- 305,254 $ETH ($674M) to #Coinbase Prime
- 146,507 $ETH ($324M) to #Paxos
- 7,800 $ETH ($17.02M) to #FalconX
Since Nov 13, 2023, Celsius Network has moved 757,626 $ETH ($1.69B) to FalconX, Coinbase, OKX and Paxos.
And currently still holds 62,469 $ETH ($138M) in address 0xdb3.
For more updates on Celsius Network, follow @spotonchain now and turn on your 🔔 at https://platform.spotonchain.ai/en/profile?address=0xdb31651967684a40a05c4ab8ec56fc32f060998d