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

Резултати

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

Пребарај: #conflictresolution

当前筛选 #conflictresolution清除筛选

👥Адамдар немесе топтар арасындағы жанжалға не әсер етеді және оны қалай шешуге болады? 👤Осы туралы 1950 жылдары америкалық психолог Музафер Шериф Оклахома штатындағы балалар лагерінде зерттеу жүргізді. Әлеуметтік психологияда бұл тәжірибе The Robbers cave (Қарақшылар үңгірі) деген атаумен танымал. 🔍Толығырақ карусельден оқыңыз ___ 👥Что приводит к межгрупповому конфликту и как можно его разрешить? 👤В 1950-х годах американский психолог Музафер Шериф провел исследование в детском лагере в Оклахоме. В социальной психологии исследование известно как Robbers cave experiment (Пещера разбойников). 🔍Подробнее об эксперименте можно узнать в карусели. #ҚҚДИ#KIPD #SocialPsychology#ConflictResolution#RobbersCaveExperiment

Crypto M - Crypto News

@CryptoM · Post #64919 · 10.04.2026 г., 09:28

🚀 Ukraine's Negotiator Optimistic About Peace Deal with Russia Ukraine's chief negotiator with Russia has expressed optimism about reaching a peace agreement with Russian President Vladimir Putin in the near future. Bloomberg posted on X, highlighting the negotiator's belief that a resolution to the ongoing conflict could be achieved soon. This development comes amid ongoing tensions and efforts to find a diplomatic solution to the hostilities between the two nations. The negotiator's comments suggest a potential breakthrough in the peace talks, which have been a focal point for international observers. The situation remains fluid, with both sides continuing to engage in discussions aimed at ending the conflict. #Ukraine#Russia#PeaceTalks#Diplomacy#ConflictResolution#InternationalRelations

የኢትዮጵያ ሀገራዊ ምክክር፡ ለዘላቂ ሰላምና ለጋራ ብሔራዊ ስምምነት አዲስ ምዕራፍ **************** የኢትዮጵያ ሀገራዊ ምክክር ኮሚሽን ከተመሠረተበት ጊዜ ጀምሮ በርካታ ውስብስብ ፈተናዎችን እየተጋፈጠ፣ ሀገራዊ መግባባትን ለማስፈን የሚያስችሉ ተጨባጭ ሥራዎችን በትጋት እያከናወነ ይገኛል። በሂደቱ በዋናነት ሁሉንም የኅብረተሰብ ክፍል ያሳተፈ፣ አካታችና ተዓማኒ ለማድረግ የሚያስችሉ የዝግጅት ተግባራትን ቅድሚያ ሰጥቶ ሲያከናውን ቆይቷል። ኮሚሽኑ ጠንካራ ተቋማዊ አወቃቀርና የሕግ ማዕቀፍ በመዘርጋት ለሥራው ምቹ ሁኔታ ከመፍጠሩም ባለፈ፣ በአዲስ አበባና በተለያዩ ክልሎች ሕዝባዊ ተሳትፎን መሠረት ያደረገ የተሳታፊዎች ልየታና የአጀንዳ ማሰባሰብ ሥራዎችን በስኬት አከናውኗል። #NationalDialogue#PeaceBuilding#ConflictResolution#NationalConsensus#EastAfrica#InclusiveDialogue

Crypto M - Crypto News

@CryptoM · Post #65219 · 12.04.2026 г., 04:08

🚀 Polymarket Odds Drop as Iran-Israel/US Conflict Talks Stall Polymarket odds for the Iran-Israel/US conflict ending before April 15 have decreased to 47%, marking a 22% drop within 24 hours. According to NS3.AI, the odds for the conflict concluding before April 30 have also fallen to 55%, down 16%. This decline follows the latest round of US-Iran talks, which ended without reaching an agreement. #Polymarket#IranIsraelConflict#USTalks#IranUSRelations#OddsDrop#ConflictResolution#April15#April30

Crypto M - Crypto News

@CryptoM · Post #65062 · 10.04.2026 г., 17:45

🚀 Iran's Leadership Revamp Amid Peace Talks with the US The ongoing conflict in Iran has prompted significant changes in the nation's leadership structure. Bloomberg posted on X that the Revolutionary Guards are set to play a pivotal role in the upcoming peace negotiations with the United States this weekend. This shift in power dynamics underscores the growing influence of the Revolutionary Guards in Iran's political landscape. The talks are expected to address key issues surrounding the conflict and aim to establish a framework for peace. Observers are closely watching how the involvement of the Revolutionary Guards will impact the discussions and the potential outcomes of these negotiations. #Iran#LeadershipRevamp#PeaceTalks#RevolutionaryGuards#USIranRelations#PoliticalLandscape#ConflictResolution#IranPolitics#PeaceNegotiations

Crypto M - Crypto News

@CryptoM · Post #65141 · 11.04.2026 г., 11:36

🚀 Russia and Ukraine Conduct Prisoner Swap Mediated by UAE Russia and Ukraine have successfully exchanged 175 prisoners of war, with the United Arab Emirates playing a mediating role in the process. Bloomberg posted on X, highlighting the significance of this exchange amid ongoing tensions between the two nations. The swap marks a notable development in the efforts to address humanitarian concerns arising from the conflict. Both countries have been engaged in a prolonged conflict, and such exchanges are seen as steps towards easing tensions and addressing the humanitarian impact of the war. The involvement of the UAE underscores the international community's interest in facilitating dialogue and resolution between Russia and Ukraine. This exchange is part of ongoing efforts to manage the humanitarian aspects of the conflict, which has drawn widespread international attention. #Russia#Ukraine#PrisonerSwap#UAE#HumanitarianEfforts#ConflictResolution#InternationalDiplomacy#HumanitarianImpact#Tensions#War