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

Резултати

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

Пребарај: #nelsonmandela

当前筛选 #nelsonmandela清除筛选
Russian Consulate in Cape Town

@rusconct · Post #3202 · 05.12.2025 г., 07:25

✨ Today we remember Nelson Mandela, South Africa’s first democratically elected president and a global symbol of the struggle for freedom, who passed away #OTD at the age of 95. Mandela’s impact reached far beyond South Africa. In Russia, a national day of mourning was declared in his honour. Russian leaders and parliament paid tribute to Madiba, acknowledging the USSR’s long-standing support for the anti-apartheid movement. ✍️ President Vladimir Putin also sent condolences, highlighting the historic ties between the USSR and the ANC during the liberation struggle. A decade later, Mandela’s legacy of justice, dignity, and reconciliation continues to inspire nations across the world. #RussiaSouthAfrica#NelsonMandela

Reuters: World

@reutersworldchannel · Post #149388 · 15.10.2021 г., 01:52

Iconic Nelson Mandela shirts go up for auction The family of former South African President Nelson Mandela is putting up around 100 of his belongings, including some of his iconic shirts, up for auction to help fund a memorial garden in his honor. #NelsonMandela#auction#News#Reuters Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

🕊 The Philosophy of Ubuntu Ubuntu is a core concept in the cultures of southern Africa, including South Africa🇿🇦 Rooted in the Bantu languages, it is often translated as: “I am because we are.” Ubuntu is about humanity, compassion, mutual support, and the ability to forgive🤝 👐Nelson Mandela believed that everyone has the power to change the world — starting with respect for others: 💬 “Ubuntu does not mean that people should not enrich themselves. The question is: are you going to do so in order to enable the community around you to be able to improve?” — Nelson Mandela 🌍 On Mandela Day 🗓 July 18, supporters of the Ubuntu philosophy around the world dedicate 67 minutes to acts of kindness, honoring 67 years of Nelson Mandela’s service to society ❤️ #Ubuntu#NelsonMandela#SouthAfrica#Philosophy#Humanity#MandelaDay

💴South African rands are, arguably, among the most beautiful banknotes and coins in the world 🌍✨ South African banknotes feature the iconic “Big Five” animals 🐘🦁🦏: • R10 — rhinoceros • R20 — elephant • R50 — lion • R100 — buffalo • R200 — leopard The reverse side of each note features Nelson Mandela, honoring his legacy as a symbol of democracy, freedom, and national unity in South Africa ✊🏿🇿🇦 #SouthAfrica#Currency#rands#BigFive#NelsonMandela#Heritage#Culture

🕊Nelson Mandela International Day, or Mandela Day, is celebrated every year on July 18, the birthday of South Africa’s legendary freedom fighter and first Black president. 🇿🇦 🗓 The United Nations officially declared the day in 2009, with the first Mandela Day held on July 18, 2010. #MandelaDay#NelsonMandela#SouthAfrica#UN#HumanRights#Ubuntu#Freedom#Justice#Inspiration#MandelaLegacy