TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #205 · 22 јан.

Как работает функция reload()? Эта функция нужна для того, чтобы перезагрузить изменившийся код из py-файла без рестарта интерпретатора. Дело в том, что любой импортированный модуль при повторном импорте не будет перечитывать файл. Функция импорта вернёт уже загруженный в память объект модуля. Чтобы обновить код, нужно либо перезапустить всю программу, либо использовать функцию reload() from importlib import reload reload(my_module) 🔸 Функция reload() принимает в качестве аргумента только объект модуля или пакета. Она не может перезагрузить класс или функцию. Только весь файл целиком! 🔸 Перезагрузка пакета перезагрузит только его файл __init__.py, если он есть. Но не вложенные модули. 🔸Она не может перезагрузить ранее не импортированный модуль. 🔸При вызове функция reload() перечитывает и перекомпилирует код в файле, создавая новые объекты. После создания новых объектов перезаписывается ранее созданный неймспейс этого модуля. Это значит, что если где-то этот модуль импортирован через import и обращение к атрибутам происходит через неймспейс (имя) модуля, то такие атрибуты обновятся. Если какие-либо объекты из этого модуля импортированы через from то они будут ссылаться на старые объекты. Напишем простой модуль # mymodule.py x = 1 Теперь импортируем модуль и отдельно переменную х из модуля >>> import mymodule >>> from mymodule import x >>> print(mymodule.x) 1 >>> print(x) 1 Не перезапуская интерпретатор вносим изменения в модуль # mymodule.py x = 2 Делаем перезагрузку модуля и проверяем х ещё раз >>> reload(mymodule) >>> print(mymodule.x) 2 >>> print(x) 1 То же самое будет если присвоить любой объект переменной (даже словарь или список) Повторный импорт обновляет значение >>> from mymodule import x >>> print(x) 2 🔸Созданные инстансы классов не обновятся после перезагрузки модуля. Их придётся пересоздать. #tricks#basic

Резултати

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

Пребарај: #polar

当前筛选 #polar清除筛选
Amazing Geography 🌍

@amazingeo · Post #78 · 19.08.2025 г., 16:12

🌍 The polar climate zones, found near the North and South Poles, have average summer temperatures below 10°C. Here, permanent ice and tundra dominate, with only hardy mosses and lichens surviving. ✨ #climate⚡#polar⚡#tundra⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍

Universe Mysteries 🪐

@cosmomyst · Post #298 · 19.09.2025 г., 20:11

🪐 The galaxy NGC 2685, also called the Helix Galaxy, is a striking example of a "polar ring galaxy," where a large ring of stars and gas orbits nearly perpendicular to the main disk. This rare and twisted structure probably formed when NGC 2685 captured material from another galaxy, creating a cosmic spectacle that challenges our ideas of how galaxies grow and evolve. ✨ #galaxies⚡#shapes⚡#polar⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries ​

Amazing Geography 🌍

@amazingeo · Post #699 · 23.04.2026 г., 20:31

🌍 Antarctica is home to “blue ice” areas where strong winds strip away snow and expose centuries-old glacier ice, creating shimmering fields that reflect nearly as much sunlight as fresh snow. ✨ #glaciers⚡#Antarctica⚡#polar⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #658 · 11.03.2026 г., 20:31

🌍 In Antarctica’s Dry Valleys, glaciers flow slowly over bare rock and create icy waterfalls called “ice falls,” frozen in mid-cascade for years in the planet’s coldest, driest desert region. ✨ #glaciers⚡#Antarctica⚡#polar⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #237 · 14.09.2025 г., 20:12

🌍 In Antarctica’s McMurdo Dry Valleys, some glaciers create striking red waterfalls called “Blood Falls.” The color comes from iron-rich water oxidizing as it flows out of the ice. ✨ #glaciers⚡#polar⚡#Antarctica⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #163 · 02.09.2025 г., 16:12

🌍 Some Antarctic glaciers can move several meters in a single day, driven by gravity and melting underneath. These "ice rivers" shape the landscape faster than most people imagine. ✨ #glaciers⚡#polar⚡#Antarctica⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #317 · 30.09.2025 г., 20:31

🌍 In polar regions, "diamond dust" can fall from clear skies. This glittering ice fog is made of tiny ice crystals that drift in the air, sparkling in sunlight even when there’s no snowstorm. ✨ #glaciers⚡#polar⚡#arctic⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #537 · 26.12.2025 г., 12:31

🌍 In polar regions, some glaciers move so fast they form towering "ice cliffs" over 100 meters high at their edges. These dramatic walls can collapse suddenly into the sea during major calving events. ✨ #glaciers⚡#polar⚡#ice⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #197 · 08.09.2025 г., 03:12

🌍 Some polar glaciers are so thick that their bottoms lie below sea level for hundreds of meters. These vast "marine ice sheets" hold enough frozen water to alter global coastlines if they melt. ✨ #glaciers⚡#polar⚡#ice⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #98 · 22.08.2025 г., 20:12

🌍 Some glaciers can glow blue beneath the surface. This vivid color appears when dense, compressed ice absorbs red light and scatters only the blue, creating striking icy caverns in polar regions. ✨ #glaciers⚡#polar⚡#ice⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #578 · 15.01.2026 г., 20:31

🌍 Some polar lakes never see sunlight and stay covered with ice year-round. Microbes living under this ice survive in complete darkness, making them some of the most isolated life forms on Earth. ✨ #glaciers⚡#polar⚡#microbiology⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

12
ПретходнаСтраница 1 од 2Следна