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

Резултати

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

Пребарај: #techhub

当前筛选 #techhub清除筛选

💻 FROM ANCIENT SCRIPTS TO DIGITAL CODE: ETHIOPIA'S TECH TAKEOVER 💻 ከጥንታዊ ጽሑፍ እስከ ዲጂታል ኮድ: የኢትዮጵያ ቴክኖሎጂ መቆጣጠር 🔥 КОГДА 3000-ЛЕТНЯЯ ЦИВИЛИЗАЦИЯ ВСТРЕЧАЕТ SILICON VALLEY! Ethiopian youth aren't just consuming technology - they're CREATING it! 💫 🌟 DIGITAL ETHIOPIA RISING: 🏙️ ADDIS ABABA = AFRICA'S SILICON VALLEY: - Tech hubs sprouting faster than coffee plants - Young developers coding the future of Africa - From ancient Ge'ez script to programming languages! 💡 ETHIOPIAN TECH STARTUPS CHANGING THE GAME: 🚀Ride - Ethiopia's answer to Uber, built for African roads 🚀ZayRide - Local mobility solutions that actually work 🚀Deliver Addis - Food delivery revolutionizing Ethiopian dining 🚀EthSwitch - Fintech making banking accessible to everyone 🚀Gebeya - Training Africa's next generation of developers 🚀iCog Labs - AI and robotics putting Ethiopia on the tech map 📊 THE NUMBERS DON'T LIE: ✨ 50%+ youth population = MASSIVE tech potential ✨ Growing internet penetration = Digital revolution in motion ✨ Government support for tech initiatives = Infrastructure backing innovation ✨ Ancient problem-solving culture + Modern tools = Unstoppable combination 🎯 YOUNG ETHIOPIAN DEVELOPERS SAY: *"Our ancestors built Lalibela without blueprints - we build apps without limits!"* *"ቅድመ አያቶቻችን ላሊበላን ያለ ንድፍ ገንብተዋል - እኛ ያለ ገደብ መተግበሪያዎችን እንገነባለን!"* 🔋 THE DIGITAL SWAG: - Coding in multiple languages (including Amharic interfaces!) - Building solutions for African problems - Connecting rural Ethiopia to global markets - Making ancient wisdom accessible through modern tech 🚀 PLOT TWIST: While Silicon Valley talks about "disruption," Ethiopia has been disrupting expectations for millennia! 💪 THE FUTURE IS BEING WRITTEN: In Ethiopian coffee shops, young developers are coding solutions that will change Africa forever! *From coffee ceremonies to coding ceremonies - the grind never stops* ☕💻 #DigitalEthiopia#የኢትዮጵያቴክኖሎጂ#EthiopianTech#AfricaTech#TechStartups#DigitalRevolution#EthiopianInnovation#TechHub#ኢትዮጵያላይፍ#FutureIsEthiopian