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 слични објави

Пребарај: #skillgaming

当前筛选 #skillgaming清除筛选
TONlines – News

@tonlines · Post #6981 · 30.04.2025 г., 11:55

⚡️TapSwap Community: Major News Incoming Tomorrow! #TapSwapBeta#SkillGaming#Web3Games TapSwap Community announces a major update about their private beta launching tomorrow, featuring three exclusive skill-based games in Telegram. Limited spots are available, and interested participants should prepare to apply using a Google form link with their Telegram handle. Source: link @tonlines

TONlines – News

@tonlines · Post #6772 · 15.04.2025 г., 09:28

TapSwap Community: Elevate Your Gaming Skills with Precision #SkillGaming#TapToWin#ClassicWithCrypto The TapSwap Community emphasizes skill and precision in classic games like Tetris, Solitaire, and Bubble Shooter. Players are encouraged to hone their focus and ability to outplay and earn, adding purpose to their gaming experience. Source: link @tonlines

Nigeria Football Hub

@football_nigeria · Post #1098 · 19.05.2025 г., 14:01

🎮TapSwap officially launched the beta! The project has made an important step forward — now skill games are available for the first testers directly in Telegram. Convenient format, fast loading and no unnecessary actions. What's included in the beta: • 🎯 Three games where the outcome depends on your skills • 💰 Integration with $TAPS • 📲 Access via Telegram mini-app ⚠️ At the current stage, only selected users have access to the beta. If you are among them, you can already try out the platform before the official release. 🗓The public launch is scheduled for early June. #TapSwap#БетаЗапуск#SkillGaming#Web3UA Bot link:tapswap_bot📱 Nigeria Football Hub

INSIDER USA | News

@insider_usa_news · Post #3352 · 19.05.2025 г., 13:04

🎮TapSwap officially launched the beta! The project has made an important step forward — now skill games are available for the first testers directly in Telegram. Convenient format, fast loading and no unnecessary actions. What's included in the beta: • 🎯 Three games where the outcome depends on your skills • 💰 Integration with $TAPS • 📲 Access via Telegram mini-app ⚠️ At the current stage, only selected users have access to the beta. If you are among them, you can already try out the platform before the official release. 🗓The public launch is scheduled for early June. #TapSwap#БетаЗапуск#SkillGaming#Web3UA Bot link:tapswap_bot📱 INSIDER USA 👉🏻 Subscribe