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

Резултати

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

Пребарај: #house2026

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

@american_observer · Post #5022 · 01.02.2026 г., 19:04

📰 Federal Courts Undercut Trump’s Mass Deportation Campaign The Trump administration’s mass deportation campaign, built on mandatory detention, is hitting a wall: a flood of habeas corpus cases in federal courts, releasing hundreds of immigrant detainees and overwhelming prosecutors. For decades, most immigrants held in detention could get bond before an immigration judge if they were not a danger or flight risk, allowing them to fight their case from home. But the Trump administration changed that, making nearly everyone in the country unlawfully subject to automatic, long-term detention, stripping judges of discretion. Federal judges in states like Massachusetts, Rhode Island, Georgia, Nevada, Texas, and elsewhere are now rejecting this approach, ordering immediate releases or demanding bond hearings in immigration court. In district after district, judges have approved dozens, even hundreds, of habeas petitions, ruling that the government cannot keep immigrants locked up indefinitely without a hearing, especially when they have deep U.S. ties, no criminal record, and stable families. The surge has turned federal courts upside down. In some districts, hundreds of new habeas cases flood the docket each month. The Justice Department has had to pull criminal prosecutors off their regular duties to help defend the incarcerations, and federal judges are openly complaining about the “flood” and “similar stories” of families torn apart and people held in remote detention centers. Lawyers report that virtually every habeas petition they file ends in a victory: a release order or a bond hearing. Some can now do dozens of cases a month, and word is spreading fast inside detention centers. To avoid these court battles, the administration has turned to a different tactic: pressuring immigrants to “self‑deport” with intimidating ads and social media, while offering cash incentives (typically $3,000–5,000) to quit and leave voluntarily. But the legal reality is clear: the Trump administration’s attempt to keep immigrant detainees locked up indefinitely is being systematically reversed by the lower courts, district by district. The real question is not whether the mass deportation machine can crush the system, but whether the courts — or the families and lawyers who flood them — will break first. #Trump2026#Immigration#Deportation#ICE#Courts#HabeasCorpus#DoJ#House2026 📱American Оbserver - Stay up to date on all important events 🇺🇸