Ранее мы уже говорили о том, как выполнить какой-либо код перед открытием интерактивной консоли.
Расскажу еще один способ! На самом деле, даже запустив интерпретатор в обычном режиме с выполнением скрипта из файла вы можете в любом месте активировать интерактивный режим. Или даже несколько по очереди. За это отвечает модуль code.
Как это может пригодиться?
🔸 Вам не хватает pdb и хочется больше "власти"
🔸 Нужно запросить у юзера данные в достаточно сложном виде. В этом случае можно попросить его создать что ему надо и сохранить в определённую переменную, с которой потом и работать.
🔸 Нужна изолированная среда для выполнения каких-либо действий.
🔸 Просто забавы ради😁
Запускается консоль очень просто
import code
ic = code.InteractiveConsole()
try:
ic.interact()
except SystemExit:
pass
Выход обратно на предыдущий уровень происходит как обычно, вызов функции exit() или клавиши Ctrl+D(Ctrl+Z для Windows).
Я набросал простой пример с некоторым функционалом
🔹 Меняются символы приглашения
🔹 В неймспейсы добавляются дополнительные объекты
🔹 Считается время, проведённое в интерактивном режиме
🔹 Скрипт просит юзера заполнить переменную и по выходу распечатывает её значение
Код здесь ↗️
Для запуска сохраните код в файл и запускайте как обычный скрипт.
python my_console.py
Для быстрого запуска можно сделать отдельный алиас
alias py="python3 /home/username/my_console.py"
#tricks#source
Nod for Vizag Metro hinges on State's financial clearance.
Visakhapatnam district administration seeks ₹600 crore from the State government for private land acquisition under the ₹11,498 crore Metro Rail project
#Infrastructure#Infra
🇮🇷🇺🇸🇮🇱 L’infrastructure pétrolière et gazière iranienne sur les sites de South Pars et d’Assalouyeh a été frappée par les États-Unis et Israël, a rapporté l’agence Tasnim.
#infrastructure#frappe#iran
Fanton EN: Game Unavailability Due to Technical Issues
#infrastructure#Yandex
Fanton EN is currently facing a service disruption due to issues with their infrastructure provider, Yandex. The Yandex team is working to restore the system, and the game will be relaunched as soon as stability is confirmed.
Source: link
@tonlines
🇺🇸🚨BIDEN ANNOUNCES MAJOR INFRASTRUCTURE INVESTMENT
🔹 President unveils $2.1 trillion infrastructure package targeting roads, bridges, and broadband expansion across 50 states 🛣️💰
🔹 Plan includes 500,000 new jobs over next 4 years, focusing on union workers and American-made materials only 👷♂️🇺🇸
🔹 Republicans slam proposal as "reckless spending spree" while Democrats call it "essential for competitiveness" 💸🔥
🔹 Package requires Congressional approval — heated debates expected over tax increases to fund the massive investment 🏛️⚖️
This could reshape America's economy or bankrupt the nation. Which side is right? 🤔💭
#USNews#infrastructure#Biden
@america
👆Cruising down the highway of prosperity!
Experience a remarkable surge in capital expenditure on National Highways, paving the way for a journey towards high growth.
#NationalHighway
#NewIndia
#Infrastructure
Ukrainian Forces Strike Key Russian Oil Infrastructure
On the night of April 7, Ukrainian forces attacked the Ust-Luga Oil terminal in Leningrad region, destroying three Transneft-Baltika tanks. Earlier, on April 5, three RVSN-20000 tanks were damaged at the Primorsk port. Additionally, primary processing units at Lukoil’s refinery in Kstovo were hit. These strikes occurred via Baltic airspace following Moscow’s warnings.
#Russia#Oil#UAF#Infrastructure
The main news of Russia and the world ishere.
Кризис DRAM меняет рынок и подход к обучению современного ИИ.
✔️ Рынок захлестнул дефицит оперативной памяти и других накопителей: ИИ-гиганты выкупили огромные объёмы DRAM, HBM и NAND. Nvidia, по слухам, прекращает поставлять дистрибьюторам видеопамять в комплекте с GPU — теперь её нужно закупать отдельно. На текущий момент цены на SSD и оперативную память выросли на 50-100% по сравнению с началом года. Производители ноутбуков и смартфонов фиксируют задержки поставок, а комплект DDR5 на 64 ГБ уже стоит дороже PS5. 🤯
✔️ Мы спросили Гигачат, как кризис повлияет на развитие нейросетей и обучение моделей. ИИ-помощник формулирует так: "Дефицит памяти — это временный дисбаланс между взрывным ростом ИИ-индустрии и производственными мощностями, которые просто не успели масштабироваться под такой спрос. Высокая стоимость памяти заставляет компании переосмыслить подходы к обучению: вместо наращивания "железа напролом" фокус смещается на эффективные архитектуры и методы.". Подробнее — в видео.
@ai_machinelearning_big_data
#ai#llm#ml#ramcrisis#infrastructure
🌍 In the Alps, some villages rely on cable cars not just for tourists but for everyday transport. Steep slopes and deep valleys make cableways a crucial link for goods and people in remote mountain areas. ✨
#transport⚡#geography⚡#mountains⚡#infrastructure⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
UK Invests Big in AI Development
The UK has announced a substantial investment plan aimed at enhancing its AI capabilities. This initiative, part of a national renewal concept, will focus on developing neural networks for government efficiency, establishing AI growth zones, and bolstering essential infrastructure like data centers and research clusters. More details can be found in the article on ForkLog.
#AI#Investment#UK#Infrastructure#Tech