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

Резултати

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

Пребарај: #artifacts

当前筛选 #artifacts清除筛选

On the Schöningen Double-Pointed Sticks In Schöningen, Germany, archaeologists found double-pointed sticks, crafted 200,000 years ago by early Europeans, likely Neanderthals. These slender wooden tools, possibly throwing sticks, showcase precise craftsmanship. Sharpened at both ends, they reflect sophisticated woodwork and hunting skill. Their balanced design suggests aerodynamic mastery for small prey. Preserved in sediment, these artifacts highlight Europe’s ancient ingenuity. #artifacts @EuropeanTribalism

Hashtags

Altar dedicated to the divine twins Mars and Venus. Marble, Roman artwork of the end of the reign of Trajan (98-117 AD), later re-used under the Hadrianic era (117-132 AD) as a base for a statue of Silvan. From the portico of the Piazzale dei Corporazioni in Ostia Antica. Shown in museum of Palazzo Massimo alle Terme, Rome, Italy #artifacts @EuropeanTribalism

Hashtags

On swastikas (18) In 2020 scientists discovered a trove in Denmark, which contained around one kilogram of gold artifacts. Among these items there was a disc depicting the Norse god Odin. The interesting thing is, that this disc can be dated to the 5th century A.D., and is thus the oldest trace of Odin worship which was ever found. The runic inscription on the disc reads "He is Odin's man". Interestingly the swastika is clearly depicted next to Odins head in the center of the disc. #artifacts @EuropeanTribalism

Hashtags

123•••67
ПретходнаСтраница 1 од 7Следна