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

Резултати

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

Пребарај: #rank

当前筛选 #rank清除筛选
MoonPlay

@moonplay_official · Post #71 · 20.07.2024 г., 07:54

Welcome, New Space Cadets! 💫 Since Monday, we've welcomed an incredible 600k new space cadetsto our mission! 🚀 With so many explorers joining, here's a quick reminder about the journey ahead. Your ship and crew are built for one epic trip only. After each successful mission to the moon, you level up and need to construct a brand new spaceship🚀 and recruit a fresh crew to set off on your next journey. 🌌New Ship: Each mission gives you the opportunity to build even cooler, more powerful ships. Your level increases with every successful expedition, unlocking better designs and greater mining power. 🌌Fresh Crew: Invite new friends to join your adventures. Each new expedition requires a full crew, and more friends mean greater strength and success. No friends? No prob! Use special bots. 🌌Continuous Exploration: The adventure never ends! Keep exploring the cosmos, completing missions, and reaping stellar rewards. 🌌Balance Intact: Levelling up doesn’t reset your Space Bucks balance. You keep all your hard-earned Space Bucks as you progress. ℹ️ For more info, check the mission manual here. Every journey helps you level up, bringing you closer to mastering the cosmos. So gear up, build your fleet, and keep pushing the boundaries of space exploration: the end of season 1 & the first token airdrop are coming!🔔 👉Start your To The Moon adventure now!👈 Website | Telegram Chat | X | Discord | Medium #ToTheMoon#MoonPlay#ecosystem#blockchain#gamefi#web3#wenlisting#squad#rank#communityfirst#taptap#clicker#game

MoonPlay

@moonplay_official · Post #69 · 18.07.2024 г., 15:10

Squad Multiplier: Earn More💰 If you haven’t joined a squad yet, you’re missing out on a fantastic way to turbocharge your 💸 earnings and complete expeditions faster. Whether you team up with friends or join forces with other players, being in a squad is your ticket to higher earnings. Head to the Crew tab—> Squads👥, check out the top squads on the leaderboard, or create your own and invite others to join. The higher your squad’s rank, the bigger the Space Bucks multiplier, up to a whopping 1.5x! After three days in a squad ⏰, you start benefiting from the squad’s multiplier. Your squad’s rank boosts your: 💸 Mining income ✅ Mission rewards 🌕 Expedition rewards 💫 Star Dust rewards So, what are you waiting for? Team up, level up, and watch your earnings skyrocket. Who’s going to be the first Rank 3 Squad in the game? Let’s wait and see! 👉Start your To The Moon adventure now!👈 Website | Telegram Chat | X | Discord | Medium #ToTheMoon#MoonPlay#ecosystem#blockchain#gamefi#web3#wenlisting#squad#rank#communityfirst#taptap#clicker#game

MoonPlay

@moonplay_official · Post #70 · 19.07.2024 г., 12:48

Can You Catch The LEPrechaun? 🍀 Hey Space Cadets! We're excited to announce a fantastic new partnership with LEPrechaun🎩! This summer, LEPrechaun is bringing a bottomless pot of $LEP coins - and you've got a chance to join the gold rush. Join their pre-launch on Telegram now and secure an airdrop for early users! But that's not all! LEPrechaun is also introducing 4 fresh missions✅ for you, our brave explorers. Head to the Missions tab and check them out to boost your progress in ToTheMoon! and start earning $CLOVER in LEPrechaun bot. Don't miss out on this stellar opportunity! 👉Start your To The Moon adventure now!👈 Website | Telegram Chat | X | Discord | Medium #ToTheMoon#MoonPlay#LEPrechaun#partnership#ecosystem#blockchain#gamefi#web3#wenlisting#squad#rank#communityfirst#taptap#clicker#game