Python + bash
Если вам часто требуется запускать shell команды из Python-кода, какой способ вы используете?
Самый низкоуровневый это функция os.system(), либо os.popen(). Рекомендованный способ это subprocess.call(). Но это всё еще достаточно неудобно.
Советую обратить своё внимание на очень крутую библиотеку sh.
Что она умеет?
🔸 удобный синтаксис вызова команд как функций
# os
import os
os.system("tar cvf demo.tar ~/")
# subprocess
import subprocess
subprocess.call(['tar', 'cvf', 'demo.tar', '~/'])
# sh
import sh
sh.tar('cvf', 'demo.tar', "~/")
🔸 простое создание функции-алиаса для длинной команды
fn = sh.lsof.bake('-i', '-P', '-n')
output = sh.grep(fn(), 'LISTEN')
в этом примере также задействован пайпинг
🔸 удобный вызов команд от sudo
with sh.contrib.sudo:
print(ls("/root"))
Такой запрос спросит пароль. Чтобы это работало нужно соответствующим способом настроить юзера.
А вот вариант с вводом пароля через код.
password = "secret"
sudo = sh.sudo.bake("-S", _in=password+"\n")
print(sudo.ls("/root"))
Это не все фишки. Больше интересных примеров смотрите в документации.
Специально для Windows💀 юзеров
#libs#linux
Language Learning Courses 📕
This section updates daily (some courses may expire fast), so save it and check it regularly.
You’ll find all kinds of language courses — not just English.
#LanguageLearning#English#Spanish#Learning#Courses
🌟 Exciting News at ADC Educational Institution!🌍✨
We're thrilled to welcome our newest team member straight from Canada! 🇨🇦 Meet Christian Bonk, a seasoned professional with a Band 9 IELTS score. 🎉✨
📚 Ready to elevate your English proficiency?
« ADC » now offers cutting-edge IELTS courses guided by Christian Bonk's expertise. 🌐📝
🗓️ Don't miss out on this incredible opportunity! Whether you're gearing up for academic goals or professional aspirations, ADC has got you covered. Contact us anytime to embark on your language journey with confidence! 🌟🚀
We have classes from morning till evening.
If you have any questions, do not hesitate to contact us I
+998742261078 | +998742281121 |
+998958505111 | +998742276163 |
+998742252536|+998952017878
or write on Telegram @admofadc
#IELTS#LanguageLearning#Education#ADCInstitution#Band9Expertise🌐📚
📚Enrollment is open for the 2025–26 academic year!
⏰24 June | 18:00
Join our Presentation of Russian Language Courses for Adults — meet the teachers and find the perfect program for you:
✨Fundamental Course — from A1 to C1, steady pace (October–June)
⚡️Intensive Course — fast-track A1 to A2, with speaking from day one
🌍Online — learn from anywhere in the world
🏫Offline — full language immersion
👥Group classes — motivation, support & shared experience
👤Individual lessons — flexible schedule, personalized approach
🎉 Plus, learn about our linguistic and cultural events for students!
📅Free participation — sign up via the linkhere
#russianlanguage#learnrussian#russiancourses#languagelearning#onlinelearning
Lesson 19 of my Uzbek self-study course teaches you how to book a table in a restaurant or café in Uzbek. Learn useful phrases, listen to dialogues with audio, and practice with exercises to master real-life situations.
https://yep.uz/en/2025/09/lesson-19-booking-a-table-in-uzbek/
#uzbeklanguage#learnuzbek#uzbeklessons#selfstudy#languagelearning#uzbekdialogues#bookingatable
Lesson 42 is out! Learn how to ask “How much does it cost?” in Uzbek. Practice the most common shopping phrases, short dialogues, and real-life expressions with audio and exercises. Start speaking confidently at the market, in shops, or while traveling in Uzbekistan.
https://yep.uz/en/2025/09/lesson-42-how-much-does-it-cost-in-uzbek/
#learnuzbek#uzbeklanguage#uzbeklessons#languagelearning#howmuch#shoppingphrases#beginneruzbek
Lesson 20 of my Uzbek self-study course with audio is here! Learn how to say countries, nationalities and languages in Uzbek. The lesson includes exercises, tables, a crossword puzzle and clear grammar explanations.
https://yep.uz/en/2025/09/lesson-20-countries-nationalities-languages-uzbek/
#uzbeklanguage#learnuzbek#uzbeklesson#languages#nationalities#countries#selfstudy#languagelearning
Want to learn how to shop in Uzbek? In this new lesson, you’ll discover useful phrases for the bazaar, shops, and buying souvenirs. Listen to the audio, repeat, and practice!
https://yep.uz/en/2025/10/uzbek-shopping-phrases-eastern-bazaar/
#uzbeklanguage#shoppinginuzbek#learnuzbek#uzbekphrases#easternbazaar#souvenirs#languagelearning#uzbeklessons
Lesson 21 of our Uzbek self-study course: digraphs sh, ch and the letter l.
Learn their pronunciation, see examples with countries and nationalities, and practice with audio exercises.
https://yep.uz/en/2025/09/lesson-21-uzbek-digraphs-sh-ch-l/
#uzbek#uzbeklanguage#uzbeklesson#uzbekalphabet#learnuzbek#languagelearning#sh#ch#LeMonde
🎉 IELTS topshirishni xohlovchilar uchun yangilik! 🎉
O'quv markazimizda taniqli o'qituvchi Danila Polikarpov IELTS imtihoniga tayyorgarlik ko'rish uchun guruhlar ochilayotganini mamnuniyat bilan e'lon qilamiz! 💼🌟
Danila bilan siz nafaqat testning har bir qismini ishonchli tarzda engishingiz, balki ingliz tilini o'rganishda shaxsiy maqsadlaringizga erishishga tayyorlanishingiz mumkin! 📚✨
Yangi guruhimizga qo'shilish va IELTS dan yuqori natijalarga erishish imkoniyatini qo'ldan boy bermang! 🚀💯
Savollaringiz bo'lsa biz bilan bog'laning
+998742261078 +998742281121
+998742276163
+998742252536 +998952017878
yoki Telegram @admofadc ga yozing
#IELTSpreparation#Englishexam#studyabroad#Languagelearning#IELTStips#Testpreparation#Englishskills#Examstrategy#AcademicEnglish #IELTSsuccess# Languageproficiency #Studygram #IELTSclass# Examgoals #Testtaking#Englishproficiency#LearnEnglish#IELTSpractice#Testprep#Languageexam