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 слични објави

Пребарај: #pulsation

当前筛选 #pulsation清除筛选
Universe Mysteries 🪐

@cosmomyst · Post #164 · 21.08.2025 г., 00:11

🪐 In the constellation Hydra, astronomers have found R Hydrae, a star that pulses in brightness over a period of about 385 days. This "Mira variable" expands and contracts like a cosmic heartbeat, changing size and light output as it nears the end of its life, giving scientists clues about the future fate of our own Sun. ✨ #stars⚡#hydra⚡#pulsation⚡#nasa⚡#galaxy⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #113 · 10.08.2025 г., 20:11

🪐 In the constellation Vela, the star system HD 74423 displays an unusual cosmic phenomenon: its shape is teardrop-like rather than round, caused by the powerful gravitational pull of a nearby red dwarf companion. This distortion leads to "heartbeat" pulsations—brightenings and dimmings in rhythm with the stars’ orbits—making HD 74423 the first known one-sided pulsating star in our galaxy. ✨ #Vela⚡#heartbeatstars⚡#pulsation⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries