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

Резултати

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

Пребарај: #spiders

当前筛选 #spiders清除筛选
Interesting Planet 🌍

@interesting_planet_facts · Post #570 · 16.08.2025 г., 13:22

🌎 In Costa Rica, the golden orb-weaver spider spins silk that glows bright gold in sunlight. This strong, shimmering web attracts pollinating insects while reflecting UV light, making it both a trap and a natural artwork. ✨ #spiders⚡#biodiversity⚡#adaptation 👉subscribe Interesting Planet

Interesting Planet 🌍

@interesting_planet_facts · Post #728 · 11.09.2025 г., 13:22

🌎 Peacock spiders from Australia show off bold, iridescent colors during their unique courtship dances. Males raise flaps on their abdomen that resemble tiny rainbows to attract females. Over 80 species have been identified, each with distinct colors and patterns. ✨ #animals⚡#camouflage⚡#spiders 👉subscribe Interesting Planet ​

Interesting Planet 🌍

@interesting_planet_facts · Post #607 · 22.08.2025 г., 13:22

🌎 A single strand of spider silk is so thin and strong that, if scaled up, it could stop a speeding jet airliner. Spider silk’s unique proteins give it greater tensile strength than steel, making it a model for future lightweight materials. ✨ #spiders⚡#biomaterials⚡#engineering 👉subscribe Interesting Planet

Interesting Planet 🌍

@interesting_planet_facts · Post #478 · 01.08.2025 г., 03:22

🌎 The silk of the Darwin's bark spider, found in Madagascar, is the toughest biological material known—over 10 times stronger than Kevlar used in bulletproof vests. ✨ #spiders⚡#materials⚡#Madagascar 👉subscribe Interesting Planet

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40053 · 09.11.2025 г., 23:01

The world’s biggest spiderweb—home to 111,000+ spiders— is found in the Cave of Sulphur on the Albanian–Greek border. Two common species built a massive colonial cobweb in a permanently dark zone—the first record of cooperative web-building at this scale. Researchers call for preservation and are preparing follow-up studies. 🕷️🕸️🌍🇦🇱🇬🇷 [Read more here] @googlefactss #Nature#Discovery#Spiders#Conservation

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40733 · 04.03.2026 г., 07:04

Jumping spiders are small spiders in the Salticidae family. They have four pairs of eyes, with large front eyes for hunting and navigation. They do not build webs to catch prey. They hunt by stalking and leaping on insects. They use silk as a safety line when they jump. Some species are kept as pets and are easy to care for. 🕷️🌿🎯 [Read more] @googlefactss #Spiders#JumpingSpider#Salticidae#Nature#Pets