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

Резултати

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

Пребарај: #toncommunity

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

@tonlines · Post #6856 · 19.04.2025 г., 17:00

STON.fi Celebrates Successful Event in Tbilisi #TON#Tbilisi#TONCommunity At the recent meet-up in Tbilisi, STON.fi brought together the TON community with passionate discussions and showcases of innovative projects. The event, co-hosted by TON Georgia, highlighted the diversity of voices contributing to the growth of the TON ecosystem. Source: link @tonlines

TON Crypto News

@toncoin_rap · Post #195 · 20.10.2024 г., 09:19

🎧⤴ 💎 Telegram’s Crypto Bot Launches Fee-Free Coin Swaps – Best Rates on TON and Beyond! Telegram’s popular Crypto Bot introduced a groundbreaking Swap feature, enabling seamless exchanges of cryptocurrencies, including TON, at optimal market prices with 0% commission. This new feature empowers users to swap tokens effortlessly, catering to the needs of both seasoned traders and beginners. As Telegram strengthens its ties with The Open Network (TON), this development marks a significant step towards making zero-fee crypto trading more accessible and user-friendly. TON, Telegram, and crypto swaps headline this exciting update. Chorus: Swap it, drop it, no fees, we poppin’, Crypto bot’s live, TON fam’s watchin’. Best market rates, yeah, that’s the notion, Zero percent, ridin’ this motion. Verse 1: Telegram’s bot, now it’s all in play, Swappin’ TON coins without delay. Zero fees stack, in a major way, Crypto’s here to stay, what more to say? Swipe right, the trades ignite, Swappin' at the best rates, day or night. TON on deck, the moves in sight, Crypto bot’s game changin’, feelin’ right. Chorus: Swap it, drop it, no fees, we poppin’, Crypto bot’s live, TON fam’s watchin’. Best market rates, yeah, that’s the notion, Zero percent, ridin’ this motion. Verse 2: From TON to ETH or BTC, quick like a flash, One tap on Telegram, and the coins clash. Zero fees givin' more green in the stash, Crypto bot’s hustle, bringin’ in cash. Telegram links up with TON, Best swaps, no cap, just get it done. In the market, bots always on the run, Swappin’ coins, and we're havin' fun. Chorus: Swap it, drop it, no fees, we poppin’, Crypto bot’s live, TON fam’s watchin’. Best market rates, yeah, that’s the notion, Zero percent, ridin’ this motion. Verse 3: Telegram and TON, now we’re connectin’, Coins on the move, the fam’s respectin’. Best rates, zero fees, no second-guessin’, Crypto's risin', it's impressin'. Swap so quick, it’s like a race, Crypto bot's here, savin' time and space. TON's in the mix, the market’s embrace, With zero fees, everyone finds their place. Chorus: Swap it, drop it, no fees, we poppin’, Crypto bot’s live, TON fam’s watchin’. Best market rates, yeah, that’s the notion, Zero percent, ridin’ this motion. Bridge: TON in the mix, we set the tone, Zero fees, we break the stone. Crypto bot's king on this throne, This is the future, watch it be known. #TONCommunity#CryptoSwap#TON #TONCryptoNewsRapStyle 🎧@toncoin_rap

🙏SBT ONTON in real time! 🔍 Our chat has a bot that monitors the emergence of new SBTs in real time — they appear instantly along with passwords! ❤️ No need to search for them in different chats anymore - just join our community and get valuable Soul Bound Tokens to your wallet, so that you can get a drop for them later! 🟣Claim your SBT ONTON now! #TON#ONTON#SBT#Airdrop#Web3#TONCommunity