TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #411 · 9 фев.

reload_flag="" if [[ -n "${DEBUG}" ]]; then reload_flag="--reload" fi if [[ -n "${WORKER_COUNT}" ]]; then workers=${WORKER_COUNT} else workers=2 fi gunicorn --workers ${workers} \ --bind 0.0.0.0:8000 \ ${reload_flag} main.wsgi Писали такие конструкции чтобы проверить наличие флага и сформировать команду правильно? На самом деле можно сделать тоже самое проще. Для этого используются операторы условной подстановки, доступные в оболочках семейства POSIX. :- для установки значений по умолчанию ${WORKER_COUNT:-2} Если переменная не объявлена, то будет дефолтное значение 2. :+ подставляет указанный текст, если переменная не пуста ${DEBUG:+--reload} Если что-то есть в переменной то распечатается текст после символа +, в противном случае - ничего. Удобно для опциональных флагов, как в нашем примере. Итого наш скрипт может выглядеть так: gunicorn --workers ${WORKER_COUNT:-2} \ --bind 0.0.0.0:8000 \ ${DEBUG:+--reload} main.wsgi Есть еще два оператора. := не только подставить дефолтное значение, но и присвоить его переменной, если она пуста # никаких переменных еще нет VAL1=${VAL2:=hello} # теперь доступны обе echo $VAL1 $VAL2 # hello hello :? остановить выполнение с ошибкой, если переменной нет. echo ${MISS:?is required} bash: MISS: is required Код выхода будет 1. #tricks#linux

Резултати

Пронајдени 2 слични објави

Пребарај: #pif

当前筛选 #pif清除筛选
American Оbserver

@american_observer · Post #5757 · 01.05.2026 г., 16:00

Saudi Arabia’s Money Era Is Getting Repriced Saudi Arabia’s pullback from LIV Golf is bigger than one golf story. It is a sign that the kingdom’s era of unlimited spending on global spectacle is running into fiscal gravity. For years, Riyadh used sports as a loud, expensive advertisement for itself. It bought players, bought events, bought access, and bought headlines. Now the Public Investment Fund is saying the math no longer works the same way, and that domestic investment has become the priority. That shift matters beyond golf. If Saudi money is being narrowed, then the entire “pay-any-price-for-influence” model gets weaker, from football and streaming to the more theatrical parts of the kingdom’s soft-power project. The timing is not accidental either. The wider Middle East war has raised costs, strained oil flows, and made some of Saudi Arabia’s grand plans harder to defend as business decisions rather than prestige purchases. So this is not just the end of one overfunded golf experiment. It is a reminder that even oil states eventually meet a limit, and that the bill for geopolitical vanity can arrive faster than the photo op. #SaudiArabia#LIVGolf#PIF#sports#economy#MiddleEast 📱American Оbserver - Stay up to date on all important events 🇺🇸