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 слични објави

Пребарај: #techregulation

当前筛选 #techregulation清除筛选
AI & Law

@ai_and_law · Post #267 · 21.03.2024 г., 08:04

Civil Society Urges Action on EU AI Act Implementation In response to the recent vote on the AI Act, various civil society organizations, including Foxglove, ARTICLE 19, the Mozilla Foundation, and the Irish Council for Civil Liberties, have voiced their perspectives on the regulation. Emphasizing the urgency of the matter, they highlight the risks posed by the dominance of major tech corporations in the AI sector. These organizations underscore the importance of swift action to address unchecked corporate power, particularly in the realm of artificial intelligence. They advocate for robust enforcement of competition rules to safeguard democracy and public interests against potential threats arising from concentrated control within the tech industry. #AIAct#CivilSociety#TechRegulation

AI & Law

@ai_and_law · Post #742 · 14.01.2026 г., 08:04

🌐📖Responsible AI Governance in 2025: From Principles to Practice The Responsible AI Governance Network (RAGN) published "The 2025 Responsible AI Governance Landscape: From Principles to Practice" in December 2025. The report maps how AI governance evolved during 2025, highlighting five major shifts: the EU AI Act moving into enforcement, the coexistence of three non-converging governance models, the rise of board-level accountability, tensions between frontier and open-source AI, and courts increasingly shaping standards through litigation. The report includes sector-specific snapshots for healthcare, HR, finance, and public procurement, and examines the operational cost of AI governance, including staffing, tooling, and audits. It also provides a 30–60–90 day implementation roadmap with a maturity self-assessment designed for organizations deploying or overseeing AI systems. The publication documents concrete governance practices observed in 2025, such as cross-functional governance teams, continuously updated documentation, CI/CD-integrated controls, independent audits for high-risk systems, and ongoing monitoring instead of one-off assessments. It also identifies common implementation failures, including checkbox compliance, fragmented tooling, accumulated documentation debt, and governance processes that exist only formally. #AIandLaw#ResponsibleAI#AIGovernance#EUAIAct#AICompliance#TechRegulation

AI & Law

@ai_and_law · Post #452 · 27.11.2024 г., 08:04

Protecting Freedom of Expression within the AI Act Framework In a recent op-ed for Tech Policy Press, Jordi Calvet-Bademunt, Senior Research Fellow at The Future of Free Speech, delves into the AI Act’s potential impact on freedom of expression. With new requirements for assessing and mitigating systemic risks tied to high-impact AI, the Act aligns with the Digital Services Act (DSA) approach but introduces significant challenges. Providers of general-purpose AI now face complex responsibilities in balancing various fundamental rights. A misstep in judgment may lead to excessive content removal, as companies seek to avoid potential penalties—a trend that could inadvertently curb free speech, particularly for contentious viewpoints. As the European Commission prepares to enforce the Act, concerns are rising about the role of political influence in managing what constitutes "public security." Past examples, like then-Commissioner Breton’s statements advocating platform shutdowns during unrest, underline the risks associated with broad regulatory powers. The upcoming General-Purpose AI Code of Practice, set to accompany the Act, presents a vital opportunity for establishing protections that better secure freedom of expression. #AIGovernance#FreeSpeech#TechRegulation#AIAct#DigitalRights