Как работает функция 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
🆕 TokenPocket Chrome Extension's Latest (1.2.3) Version has enabled Nostr Protocol by default! #Nostr
👉https://extension.tokenpocket.pro/#/
✅With no complex setting steps, all the TokenPocket users can get their own Nostr address easily!
🎯Your Points Matter! TokenPocket will keep working on listening to communities' voices and optimizing users' experience. #TokenPocket#nostr
How to enable Nostr Protocol on TokenPocket Mobile wallet?
Guide 👉https://help.tokenpocket.pro/en/wallet-operation/protocol/nostr
【Details】https://twitter.com/TokenPocket_TP/status/1745755553039802879
【Powered By】Crypto Box
🔵Enjoy Nostr Protocol on TokenPocket_TP.
TokenPocket now supports #Nostr Protocol on Mobile Wallet and Chrome Extension Wallet. You can easily enable your #Nostr address on #TokenPocket!
Guide👇
https://tokenpocket-gm.medium.com/enjoy-nostr-protocol-on-tokenpocket-b53044dd10f0
【Details】https://twitter.com/TokenPocket_TP/status/1733450921391358056
【Powered By】Crypto Box
#Nostr Protocol is now available on TokenPocket_TP!
🔥TokenPocket now provides the Nostr support for #Bitcoin, dogecoin network, and all the EVM-compatible networks!
How to enable Nostr in your TokenPocket wallet?
🔵Android: Tap “Me” - “Experience” - Enable Nostr. You can get your Nostr address by tapping “Details” on the Assets Page.
🔵iOS: Tap “Me” - “Setting” - Turn on “Nostr”. You can get your Nostr assets by tapping “Details” on the Assets page.
#taproot#bitcoin#Nostr
【Details】https://twitter.com/TokenPocket_TP/status/1724712691523100844
【Powered By】Crypto Box
🌟Nostr Protocol is Live On TokenPocket!
>Both on Mobile Wallet and Chrome Extension.
And Nostr Protocol is available for all the EVM-compatible networks, #Bitcoin, and also #Dogecoin on TokenPocket!
🔥Nostr is a simple, open protocol for a global, decentralized, and censorship-resistant social networking system.
📝Here is the tutorial to guide you on how to enable/support #Nostr on your TokenPocket wallet.
👉https://help.tokenpocket.pro/en/wallet-operation/protocol/nostr
🔥#Nostr Protocol is Live On TokenPocket_TP!
>Both on Mobile Wallet and Chrome Extension.
🔥Nostr is a simple, open protocol for a global, decentralized, and censorship-resistant social networking system.
Here is the tutorial to guide you on how to enable/support #Nostr on your TokenPocket wallet.
👉https://help.tokenpocket.pro/en/wallet-operation/protocol/nostr
📣All in TokenPocket! #Nostr#EnableNostr#Bitcoin
👉https://www.tokenpocket.pro/
👉https://extension.tokenpocket.pro/ NoScription
【Details】https://twitter.com/TokenPocket_TP/status/1741998782320136275
【Powered By】Crypto Box
#Bitcoin Eco is on fire!!🔥🔥🔥
TokenPocket Mobile Wallet now provides a super easy-to-use experience for most #Nostr-based DApps. Recently, we also noticed that there is a new product live on #Nostr Protocol. NostrAssets
📣You can discover Nostr Assets on NostrAssets with #TokenPocket and access the new era of #Bitcoin Eco.
> Enter "NostrAssets" on your Discover page then you can find it! ✅✅
Just the beginning!
💥 Let's work together and bring more highlights to #Bitcoin! #Taproot
❓How to enable #Nostr on your TokenPocket?
Tutorial👉https://help.tokenpocket.pro/en/wallet-operation/protocol/nostr
【Details】https://twitter.com/TokenPocket_TP/status/1719933875059855422
【Powered By】Crypto Box
#AMA TokenPocket × NostrSwap
⏰Jun 29th, 1 PM UTC
🪑 Venue: https://t.me/tokenPocket_en
✅Comment your Qs about NostrSwap, #BRC20 and #Nostron Twitter before AMA.
✅Join Telegram and enjoy the live AMA
🎁100 USDT to 5 best Twitter Qs & 5 best Live Qs
Zapstore
Permissionless and social app store built on the #nostr protocol
For #Android#Linux and #Mac
https://zapstore.dev
Download
https://zapstore.dev/download/
Sources
https://github.com/zapstore
Secure by default
Everything you install comes from trusted sources and is cryptographically verified. Not satisfied with the default? Choose your own curators, or mix and match! Censorship has no place in our world.
Relevant to you
Supercharged by the nostr open protocol, recommendations come right from your social connections — or use it in totally private way. With our growing catalog, you will never run out of great apps.
Support your devs
Connect with your favorite developers: send them direct feedback, request features and support them through micropayments, all without any middlemen.
#apk#store