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

Резултати

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

Пребарај: #airisk

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

@ai_and_law · Post #789 · 20.03.2026 г., 08:04

❗️AI Becomes #2 Global Business Risk in Allianz Risk Barometer 2026 According to the 2026 report by Allianz, artificial intelligence has risen to #2 among global business risks, up from #10 in 2025. This is the largest increase recorded in the ranking’s history. AI is now ranked #2 in the Americas, Asia Pacific, and Africa and the Middle East, and #3 in Europe, placing it among the top three risks for companies of all sizes. The report links this rapid rise to both the risks associated with AI systems and their broader societal, political, and economic implications. Since the launch of ChatGPT in 2022, AI deployment and automation have expanded significantly, with further applications in development. AI risk is also closely connected to other major categories, including cybersecurity (the top-ranked risk) as well as political risks, macroeconomic developments, and regulatory changes. #AIrisk#AIGovernance#AIRegulation#Cybersecurity#TechPolicy#RiskManagement

AI & Law

@ai_and_law · Post #734 · 30.12.2025 г., 08:04

🇺🇸OpenAI Seeks New Head of Preparedness to Address Emerging AI Risks OpenAI has opened a search for a Head of Preparedness, a senior executive role tasked with studying and managing emerging risks linked to advanced AI systems. According to CEO Sam Altman, these risks now include models that can meaningfully affect mental health and systems that are becoming capable of identifying critical computer security vulnerabilities. The role is framed around anticipating and mitigating severe harms as frontier AI capabilities evolve. The position will be responsible for executing OpenAI’s preparedness framework, which sets out how the company tracks, evaluates, and prepares for high-impact risks arising from powerful AI models. Altman highlighted challenges such as enabling cybersecurity defenders without empowering attackers, managing the release of sensitive capabilities (including biological ones), and gaining confidence in the safety of systems that may be able to self-improve. The job listing underscores that preparedness is being treated as a core governance function rather than a peripheral safety task. Compensation for the role is listed at USD 555,000 plus equity, signaling the strategic importance OpenAI places on institutional risk oversight as AI capabilities continue to advance. #AIПovernance#AIsafety#AIrisk#TechPolicy#ResponsibleAI