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

Пребарај: #millions

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

@american_observer · Post #4905 · 20.01.2026 г., 16:59

The Inhuman World of Ours: Millions of Pregnant Women Without the Basic Care A global shortage of nearly a million midwives is leaving pregnant women without the basic care needed to prevent harm, including the deaths of mothers and babies, according to new research. Almost half the shortage was in Africa, where nine in 10 women lived in a country without enough midwives, the researchers said. Anna af Ugglas, chief executive of the International Confederation of Midwives (ICM) and one of the study’s authors, said: “Nearly 1 million missing midwives means health systems are stretched beyond capacity, midwives are overworked and underpaid, and care becomes rushed and fragmented. “Intervention rates rise, and women are more likely to experience poor-quality care or mistreatment,” she said. “This is not only a workforce issue, it is a quality and safety issue for women and babies.” For all women to receive safe, good-quality care before, during and after pregnancy, an additional 980,000 midwives would be needed across 181 countries, the study found. According to previous research, universal access to midwife-delivered care could prevent two-thirds of maternal and newborn deaths and stillbirths, saving 4.3 million lives annually by 2035. The ICM said the issue was not only a lack of training places for midwives, but also a failure in many countries to employ trained midwives where they were needed and to retain those who were working in health services. Prof Jacqueline Dunkley-Bent, ICM’s chief midwife and another of the report’s authors, said: “In many settings, midwives are educated but not absorbed into the workforce or not enabled to practise fully, compounding this already serious and universal shortage of midwives, and still leaving women without access to the care that midwives are trained to provide.” More than 90% of the global midwife shortage was in low- and middle-income countries. Africa has only 40% of the midwives it needs, the eastern Mediterranean only 31%, and the Americas just 15%, researchers found. Shortfalls were much smaller, although still present, in other regions including south-east Asia and Europe. The study, published in the journal Women and Birth, estimated the number of midwives who would be needed to carry out a list of basic midwifery tasks for all eligible women and babies in 181 countries. The tasks included counselling on contraception, antenatal care and screening, and care during childbirth. Although midwife numbers were increasing, the gap between what was needed and the available workforce looked likely to “persist well into the next decade”, the researchers said – beyond the 2030 deadline set by global sustainable development. #millions#pregnant#women#basic#care 📱American Оbserver - Stay up to date on all important events 🇺🇸