Как работает функция 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
Explainer from #Addis_Standard Newsroom:
As of 24 February, Addis Standard has not received any formal written notice, legally mandated opportunity to respond, or reasoned decision preceding the #Ethiopian Media Authority’s public claim, made via social media, that our online media registration was revoked.
Ethiopian media law is clear: suspension or revocation of a media license must follow a defined process, including written notice, a 14-working-day right of response, a reasoned decision, and access to appeal before the Authority’s Board of Directors.
None of these mandatory steps have been observed. Addis Standard remains fully operational and continues its public-interest journalism in good faith, while its publisher, #JAKENN Publishing PLC, pursues clarification and rectification through lawful channels. This matter goes beyond one newsroom, it concerns whether media regulation in Ethiopia is governed by law, due process, and institutional accountability.
Read the explainer: https://addisstandard.com/?p=55392
News: Publisher challenges #EMA’s revocation of Addis Standard registration, cites due process violations
#JAKENN Publishing P.L.C., the publisher of #Addis_Standard, has formally contested the decision by the #Ethiopian Media Authority (EMA) to revoke the outlet’s online media registration certificate, arguing that the move lacks legal basis and violates due process guarantees under Ethiopian law.
The response follows an announcement circulated on the Authority’s official social media channels on 24 February 2026, stating that Addis Standard’s registration had been revoked.
In a letter addressed to the EMA Board of Directors, JAKENN said a legal review found the announcement “exceeds the Authority’s procedural powers” and is incompatible with safeguards provided under Media Proclamation No. 1238/2021, as amended by Proclamation No. 1374/2025.
The publisher stressed that Addis Standard is operated by JAKENN Publishing P.L.C., a legally registered private....
Read more: https://addisstandard.com/?p=55387
News: #Ethiopian Media Authority revokes Addis Standard’s online media registration; Editor-in-Chief disputes claims
The Ethiopian Media Authority (#EMA) has announced the revocation of the online media registration certificate of #Addis_Standard, effective 24 February 2026, citing repeated violations of media ethics, national laws, and what it described as the country’s national interests.
The statement did not specify which reports or actions formed the basis of the decision.
Responding to the EMA’s announcement, Yonas Kedir, Editor-in-Chief of Addis Standard publications, rejected the Authority’s claims, saying the outlet had never received any formal notices of violations.
“The claim that Addis Standard received repeated notices is factually incorrect. At no point has the Ethiopian Media Authority formally notified Addis Standard newsroom of any prior violations or enforcement actions,” he said. He added that the publisher, #JAKENN Publishing PLC, ..…
Read more: https://addisstandard.com/?p=55383
News: #CPJ calls for release of #Addis_Standard editor seized by unidentified men
The Committee to Protect Journalists has called on #Ethiopian authorities to urgently locate and release #Million_Beyene, who was taken by unidentified individuals from the newsroom of Addis Standard in the capital.
In a statement issued on April 16, CPJ said Million was seized on Wednesday morning by a group of men in plainclothes from the outlet’s newsroom in #Addis_Abeba and taken to an undisclosed location.
#JAKENN Publishing PLC, publisher of Addis Standard, says the whereabouts of its Managing Editor, Million Beyene, remain unknown nearly 24 hours after he was taken by unidentified individuals from the newsroom.
In an update issued this morning, the publisher said concerns are growing over his safety, noting that his family is “increasingly distressed and deeply concerned.”
CPJ described the incident as alarming and urged authorities to determine those responsible
Read more: https://addisstandard.com/?p=56534