Как работает функция 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
Hey, you can check your $ZRO Token Airdrop eligibility on TokenPocket!
📱Open TokenPocket > Switch to the Discover page > You can see the DApp on the Airdrop Zone!
💻You can get the checking page on TokenPocket's DApp Store!
👉https://tokenpocket.pro/en/dappstore
Good luck! 💙#LayerZero
Layer Zero AirDrop Starts NOW!
All active participants will receive a guaranteed drop of $ZRO tokens.
Airdrop : https://linktr.ee/labslayerzero
A total of 12.000.000 $ZRO coins have been allocated, time is limited!
#layerzero#airdrop#tokens#coin
📋The sensational #LayerZero (ZRO) is trading at $ 3.05 and the current circulation of unlocked coins is only $ 770 million, the total capitalization is also small - $ 3 billion, which is 2-3 times less than Aptos or SUI. #zkSync (ZK) has a similar picture, the total capitalization is even more than ZRO by 900 million.
🧐It looks very modest, I think few people predicted this. Looking at this picture, you start to worry about the rest of the altos with large capitalization. And looking at the small ones, you also think about it. After this, is it possible to believe in a further correction of Chia (XCH)?
🥸Both projects are technologically advanced, but in different aspects. zkSync focuses on scaling and efficiency within a single blockchain (Ethereum) using advanced cryptographic techniques. LayerZero is aimed at improving the interaction between different blockchains, which is also an important task for the entire industry.
😎I think for #ZRO and #ZK you need to allocate a place in your portfolio, lay a theoretical descent lower by 30-50% and start buying a ladder from the current level, of course we are talking about spot. That is, to allow a speculative decrease in ZRO to $ 2.1 and ZK to $ 0.13 due to a speculative decrease and liquidation of longs on futures. But you need to understand that the current price is already very attractive, you need to partially buy now.
0⃣#ZRO + #Tether = 🚀🚀🚀
Tether recently invested in #LayerZero, and you know they don't drop cash without deep due diligence. 🕵️♂️ The fundamentals are rock solid.
This rally is just the beginning. 🌤 I’m stacking as much $ZRO as possible. targeting 2x - 5x gains! 💸
Get in or get left behind.👋
#DeFi#BullRun $ZRO #ZROUSDT
https://x.com/CryptoBull_360/status/2021403228970315928?s=20
Bitcoin: Panic Buying Amid Market Shakeup
Panic reactions in the market are evident as Bitcoin fluctuates. Key developments in the TON ecosystem include:
- TVM Ventures launching a $100M fund for TON growth 🔗
- Updates from TON Core for Dec 2024 - Jan 2025 🔗
- Steve Yun discusses DeFi’s future in Telegram on CNBC 🔗
- First mid-core web3 game launched on TON 🔗
- Support program for Mini Apps initiated 🔗
- Innovations from Notcoin team highlighted 🔗
- LayerZero’s new USDT bridge enhances TON’s cross-chain capabilities 🔗
- Key investments in DeFi and SocialFi detailed by TVM Ventures 🔗
- TON’s ecosystem expands beyond major project monopolies 🔗
- TRM Labs introduces a comprehensive blockchain analysis tool for TON 🔗
- The domain believers.ton is permanently lost 🔗
#Bitcoin#DeFi#TON#Crypto#Web3#Investment#LayerZero#Blockchain#MiniApps#PanicBuying#TVMVentures#Notcoin#TRMLabs
Multiple Fundraising Rounds Announced
Several companies secured funding recently:
- OpenCopilot raised $1.52M for AI customer support.
- Archive Intel secured $1.50M for AI-driven data archiving solutions.
- Serene obtained $1.14M using AI for customer insights and compliance.
- Sytrex raised $1.10M to aid financial institutions.
- Tire Swing acquired $500K focusing on cybersecurity.
In other news, the SEC sues Elon Musk over misleading shareholders during the Twitter acquisition, and Meta plans to lay off 3,600 employees for inefficiency. More updates on AI job creation and Bitcoin market analysis suggest significant changes ahead.
#Funding#AI#Crypto#SEC#ElonMusk#Meta#Bitcoin#CustomerSupport#DataArchiving#FinancialInstitutions#AIJobs#LayerZero#Serene#Sytrex#TireSwing#ArchiveIntel#OpenCopilot