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

Резултати

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

Пребарај: #permafrost

当前筛选 #permafrost清除筛选
Interesting Planet 🌍

@interesting_planet_facts · Post #825 · 27.09.2025 г., 22:11

🌎 In the Norwegian Arctic, the town of Longyearbyen bans dying at home, as bodies can't decompose in permafrost. Residents who are terminally ill must travel to the mainland. This small settlement is also the northernmost town with over 1,000 people. ✨ #arctic⚡#settlements⚡#permafrost 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #580 · 18.08.2025 г., 00:22

🌎 The Siberian permafrost preserves ice age seeds for tens of thousands of years. Scientists have revived ancient plants, like Silene stenophylla, from seeds frozen over 30,000 years ago—proving some life can return after millennia in the deep freeze. ✨ #permafrost⚡#botany⚡#revival 👉subscribe Interesting Planet

Interesting Planet 🌍

@interesting_planet_facts · Post #729 · 11.09.2025 г., 16:22

🌎 Norilsk, Russia, is a city built above the Arctic Circle and is so remote that it’s closed to most foreigners. Founded in 1935 for nickel mining, it endures harsh winters with temperatures as low as −55°C. Norilsk is one of the largest cities in continuous permafrost and has no rail or road connection to the rest of Russia. ✨ #Norilsk⚡#Arctic⚡#permafrost 👉subscribe Interesting Planet ​

Amazing Geography 🌍

@amazingeo · Post #206 · 09.09.2025 г., 16:12

🌍 Some tundra soils contain buried ice wedges that can be thousands of years old. When permafrost thaws, these ancient ice wedges melt, creating strange sinkholes called "thermokarst." ✨ #permafrost⚡#tundra⚡#landscape⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #547 · 31.12.2025 г., 12:31

🌍 In tundra landscapes, some mosses and lichens can survive temperatures below –50°C and continue to photosynthesize under snow, making them some of the Earth’s hardiest plants. ✨ #tundra⚡#permafrost⚡#adaptation⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #668 · 21.03.2026 г., 20:31

🌍 In the far north, frozen permafrost soils hide ancient bacteria and seeds that can survive for thousands of years—emerging only when the tundra thaws after centuries of deep freeze. ✨ #permafrost⚡#tundra⚡#arctic⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #626 · 11.02.2026 г., 20:31

🌍 In the Siberian tundra, permafrost preserves massive underground "ice wedges" that crack open each winter and refill with meltwater every spring, leaving polygon patterns visible from above. ✨ #permafrost⚡#tundra⚡#arctic⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #439 · 07.11.2025 г., 12:31

🌍 Some tundra ponds form when summer sun thaws just the surface of permafrost, creating seasonal lakes that vanish each year. These ponds support bursts of life in otherwise frozen landscapes. ✨ #tundra⚡#permafrost⚡#arctic⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #326 · 03.10.2025 г., 12:31

🌍 In the Arctic tundra, some permafrost layers are over 1,500 meters thick—deeper than most skyscrapers are tall. This frozen ground stores ancient DNA from plants and animals tens of thousands of years old. ✨ #permafrost⚡#tundra⚡#arctic⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #245 · 16.09.2025 г., 03:12

🌍 In some Arctic tundra areas, ancient animal tracks remain frozen in permafrost for thousands of years. When the ground thaws, these footprints reappear, revealing hidden stories of past wildlife. ✨ #permafrost⚡#tundra⚡#Arctic⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Interesting Planet 🌍

@interesting_planet_facts · Post #1120 · 11.12.2025 г., 18:11

🌎 Every summer in Siberia, mysterious craters known as "Yamal holes" appear in the Arctic tundra. These giant pits, sometimes 20 meters wide, form when underground methane gas builds pressure and violently explodes through permafrost. Scientists have identified at least 17 such craters since 2014, linking them to warming temperatures and melting ice. ✨ #permafrost⚡#methane⚡#explosions 👉subscribe Interesting Planet 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #708 · 06.05.2026 г., 20:31

🌍 In parts of Siberia, thawing permafrost can trigger sudden ground collapses called “thermokarst.” These sinks reshape the tundra and can swallow trees or create lakes almost overnight. ✨ #permafrost⚡#tundra⚡#landforms⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

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