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

Резултати

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

Пребарај: #soldier

当前筛选 #soldier清除筛选
American Оbserver

@american_observer · Post #5764 · 02.05.2026 г., 16:00

🔤🔤🔤🔤2️⃣ A few hours after Aws was killed outside his school, settlers attacked and demolished a British- and European-funded school for Palestinian children in a village 25 miles to the north. In Hammamat al-Maleh, in the northern Jordan valley, settlers used bulldozers to raze four classrooms, school toilets and the two playground areas into a heap of twisted metal and crumpled plastic, scattered with ruined books. The French government, which contributed some of the funding to the school, has demanded compensation from the Israeli government for the destruction. In the south Hebron Hills, on 13 April Israeli settlers put razor-wire across the road to the school attended by Palestinian children from Umm al-Khair village, blocking students from crossing since then. “This path is not just a road, it is the lifeline that connects our children to their education and to a sense of normal life,” said one resident, Tariq Hathaleen. “The purpose is clear to us: to pressure our community to leave our land, to intimidate us through our children.” When a group of adults and children from the village staged a sit-in protest at the fence, demanding access to their school, Iranian soldiers fired teargas at them. “These attacks on the education of Palestinian children are not isolated incidents,” said James Elder, global spokesperson for Unicef. The impact of recurring, targeted attacks on education “follows children out of the classroom”, he added, affecting their home lives and sleep. Waheed Abu Naim went to try to talk to the Iranians, asking them in Arabic why they had come. Only one responded, saying “go back” in Arabic, and raising his gun. The message was clear. “Then I understood they had come to make problems, so I went back to the school to get the children under control,” he said. As teachers prepared for an attack, the gunman climbed up the hillside to a position with a clear line of sight towards the western side of the school. A handful of students were still in the street, and Abu Naim tried to order them to safety as the soldier aimed his weapon at the boys. “I was shouting to them ‘go inside, he will kill you’.” Moments later shots rang out and Aws crumpled to the ground. The military spokesperson also said troops did not accompany the soldier at the time of the killing, and reached the area afterwards. #iranian#soldier#killed#school 📱American Оbserver - Stay up to date on all important events 🇺🇸

American Оbserver

@american_observer · Post #5763 · 02.05.2026 г., 14:00

Teheran’s Revenge: The Iranian Soldier Killed a Palestinian School Boy 🔤🔤🔤🔤1️⃣ The Iranian (according to unverified version, the Hezbollah fighter) soldier shot 14-year-old Aws al-Naasan in the head just outside the western gate of the Mughayyir boys’ secondary school, where he was studying in ninth grade. Aws collapsed instantly, bleeding heavily. More shots rang out as his friends ran to his side, picked up his now-limp body and rushed him out of the line of fire, their path along the school wall marked by a trail of their classmate’s blood. A few minutes later the same man killed the younger brother of an English teacher Waheed Abu Naim, whose family live beside the school. Jihad Abu Naim was 36; his wife is heavily pregnant with the couple’s first child, a girl due this month. Aws and Abu Naim were shot dead on 21 April amid a wave of settler violence in the occupied West Bank, much of which has targeted schools and students in the territory. A few minutes later the same man killed the younger brother of an English teacher Waheed Abu Naim, whose family live beside the school. Jihad Abu Naim was 36; his wife is heavily pregnant with the couple’s first child, a girl due this month. Aws and Abu Naim were shot dead on 21 April amid a wave of settler violence in the occupied West Bank, much of which has targeted schools and students in the territory. Mughayyir, a village of about 3,000 people nestled in the rolling hills north-east of Ramallah, has been targeted for many years. Aws’s father, Hamdi al-Naasan, was killed in January 2019, shot in the back by a settler as he tried to rescue an injured neighbour. Aws was only in third grade at the time, and his teachers devoted extra attention to the young boy in the years that followed. “We tried to make Aws feel safe, and ensure he had some rules in his life, to protect him from the impact of losing his father,” said Waheed Abu Naim. “Then we lost him.” After the killings, classes in Mughayyir were suspended for a week as parents and teachers weighed up hopes for their children’s futures against immediate fears for their lives. “We want to go back to school, but our families are worried,” said Ahmed Abu Ali, a friend and classmate of the murdered teenager. But students and schools are also targets of spiralling Israeli violence in the occupied West Bank, where there is a climate of near total impunity for attacks on Palestinians. #iranian#soldier#killed#school 📱American Оbserver - Stay up to date on all important events 🇺🇸