Ранее мы уже говорили о том, как выполнить какой-либо код перед открытием интерактивной консоли.
Расскажу еще один способ! На самом деле, даже запустив интерпретатор в обычном режиме с выполнением скрипта из файла вы можете в любом месте активировать интерактивный режим. Или даже несколько по очереди. За это отвечает модуль 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
BREAKING NEWS!
Saudi Arabia is still building The Line – the wall city in the desert.
Footage released by aerial photography company Ot Sky shows work commencing on The Line megacity, which is being built as part of the Neom development in Saudi Arabia.
The drone footage shot by Ot Sky shows construction underway on the linear city, which is being built in the northwest of Saudi Arabia.
In the video, numerous excavators can be seen digging a wide linear trench in the desert. Within the trench, foundations for the city, which is planned to be 170 kilometres long, are expected to be built.
The works could also show preparation for an underground transport system that is planned to be built underneath the length of the city.
Unveiled earlier this year, The Line has been designed to house nine million people. It will be 500 metres tall and have a mirrored facade.
#archidaily#architecture#arch_shovel
Could Nantong Urban Agricultural Park Scenery Tower be the product of extraterrestrial inspiration?
According to Z-ONE Tech, the firm in charge of the A+Award-winning project, the shape of the tower is actually inspired by a grain of rice. The forward-thinking structure, completed with an inner spiral steel staircase and a circular observation deck reveals the broad fields of the Nantong Park in their full richness. #ArchitizerAwards
📸: Z-ONE Tech
#archidaily#arch_shovel#architecture
Ferring pharmaceuticals A/S has opened its new home in Copenhagen.
The site occupies a pivotal waterfront position alongside the Øresund crossing, just north of Copenhagen International Airport. Bordered by predominantly low-rise development, the building affords fantastic views towards Malmö and the Swedish coast – where the company was founded.
“We worked with Ferring to develop an in-depth understanding of the way they work. Through observations and targeted interviews, we gained valuable insight into the processes involved in the development of their drugs. In turn, we have designed a building that responds to the company’s specific needs and brings the range of Ferring’s activities under one roof.”
Architecture by Foster&partners
#arch_shovel#architecturelover#detail#archidaily
Living spaces:
1. Conde Duque apartment in Spain by Sierra + De La Higuera
2. Puro Hotel in Krakow in Poland by Paradowski Studio
3. Reforma de una Vivienda en Encsanhe in Spain by Arquitectura-G
4. Dream Weaver Penthouse in Australia by YSG
📸 by German Sáiz , Pion Studio , José Hevia, Prue Ruscoe
#interiors#lookbooks#archidaily#arch_shovel
KAPSARC awarded five LEED EBOM Platinum certifications by the US Green Building Council
.
The only buildings in Saudi Arabia to receive Platinum LEED Existing Building: Operation & Maintenance (EBOM) certification, KAPSARC’s five community facilities achieved the highest sustainability standards throughout the centre’s design, construction, operations and maintenance procedures.
.
KAPSARC’s waste management program diverted 94% of solid waste from landfill through waste stream audits that eliminated single-use goods and developed an effective waste segregation strategy across multiple stages. KAPSARC also reduced the compound’s water consumption by 30% with weather-based micro-irrigation, mulching, native planting and efficient faucets. The centre’s energy usage was also reduced by 35% with energy audits regularly identifing energy conservation measures.
.
#architecture#zahahadid#zahahadidarchitects#architecture#arch_shovel#archidaily
Chybik kristof unveils a newly designed private art gallery, defined by its shimmering facade of moveable copper tiles. the cluster of vertical cylinders are animated by the dynamic skin, which will gradually transform with a patina over time.
Visualization: monolot.studio
#rendering#cgi#facade#architect#archidaily#arch_shovel
P E A C E F U L / Grooming Retreat by Gartnerfuglen + Mariana de Delás
The #minimalspace (3x3 meters footprint), functions as a #groomingretreat for one person. The structure, made by local #timberframes , elevates the cocoon to have exclusive views whilst giving a sense of translucent privacy to the user.
.
Layers of white netting frames are interlaced throughout the interior to grant different opacities for each specific use. The subtle introvertness of the structure encourages the user to take a break from the multitasking contemporary madness, and centre on individual mental and bodily hygiene. With importance on grooming’s #meditative (not cosmetic) qualities, the space inspires the user to devote time to the reconnection of the mind to the shell.
#arch_shovel#architecture#archidaily
From cotton to culture - Oscar Niemeyer Sphere - Baumwollspinnerei.
#leipzig#visitleipzig#architecturephotography#minimalism#facadedesign#archidaily#arch_shovel
Happy World Architecture Day!
Visualization: Plo.mp
Project: Mixed-Use Complex with Kohn pedersen fox
.
#rendering#facade#architect#archidaily#minimalist#detail#architecturelover#arch_shovel