Подразумеваемые неймспейсы или неявные пакеты.
Этот функционал добавлен в Python 3.3
Что он означает?
Ранее, до 3.3 пакетами считались лишь директории, в которых есть файл __init__.py.
Этот файл одновременно являлся свидетельством того, что директория это Python-пакет, и служил "телом" этого пакета. То есть местом, где можно написать код, как это делается внутри модуля. Этот код исполняется в момент импорта пакета, так что его принято называть "код инициализации пакета".
Начиная с версии 3.3 Любая директория считается пакетом и Python будет пытаться использовать любую директорию для импорта.
Конечно, не любую в файловой системе, а только те что находятся в sys.path.
Это значит, что теперь __init__.py нужно делать только если:
🔸 вам требуется создать код инициализации пакета
🔸 нужна совместимость со старыми версиями Python
На мой взгляд это немного упрощает разработку, делает её чище, но с другой стороны убивает некоторую однозначность происходящего.
Например, я создал репозиторий со своей библиотекой и рядом положил код примеров или тестов.
repo_name/
my_library/
__init__.py
main.py
examples/
exam1.py
exam2.py
В этом репозитории пакетом является только my_library, остальные директории это не пакеты, это просто дополнительный код в файлах. Директория examples не добавлена в sys.path, в ней нет рабочих модулей. Но если она лежит рядом с my_library, то Python вполне сможет импортнуть из неё модули, так как посчитает что examples это валидный пакет.
Конечно, пример несколько надуманный. Никто не будет добавлять корень репозитория в sys.path. Но, я думаю, суть ясна. Иногда директория это просто директория а не пакет!
#basic#pep
#TakeResponsibility
If you observe any of these signs and symptoms, visit a healthcare facility for an accurate diagnosis and treatment.
Ensure you take extra precautionary measures while visiting to prevent the risk of spread.
Fake news can cause unnecessary anxiety and panic. PAUSE, and verify before you share!
Citizens are urged to take the recommended actions required to protect their families, friends, and selves.
🔗
https://ncdc.gov.ng/news/493/official-statement-on-the-new-covid-19-subvariants
#TakeResponsibility
Seek the advice of a qualified healthcare professional when you feel sick.
Self-medication can be harmful.
#TakeResponsibility by using antimicrobials appropriately
Seek the advice of a qualified healthcare professional when you feel sick.
Self-medication can be harmful.
#TakeResponsibility by using antimicrobials appropriately
Meningitis can affect any age group but is more common in children and young adults.
Visit a health center facility for immediate attention if you observe any of the below symptoms.
#TakeResponsibility to stay safe
Drugs save lives, however, they can harm when not taken properly.
Using drugs “anyhow” makes the treatment of infections more difficult.
Visit a healthcare professional when sick for accurate diagnosis and treatment.
Do not self-medicate!
#TakeResponsibility
Parents & caregivers should ensure that their children/wards receive the anti-diphtheria vaccine as recommended in the NPHCDA childhood immunisation schedule.
Visit a primary health care centre close to you to get the vaccine.
#TakeResponsibility
Parents & caregivers should ensure that their children are fully vaccinated against diphtheria with three (3) doses of the pentavalent vaccine as recommended in the childhood immunisation schedule.
#TakeResponsibility to protect yourself & loved ones
🔗
https://ncdc.gov.ng/news/435/diphtheria-public-health-advisory-amidst-outbreak-in-nigeria
The elderly, immunocompromised and those with existing health concerns are advised to:
➡️Wear face masks in outdoor spaces
➡️Wash hands regularly with clean water and soap
➡️Use hand sanitisers
➡️Avoid large gatherings
#TakeResponsibility to stay safe and healthy.
A clean environment and proper hygiene limit the spread of infectious diseases.
Clean all surfaces frequently and do not share personal items.
#TakeResponsibility to protect yourself and your loved ones.
To protect yourself and loved ones from Ebola virus disease, #TakeResponsibility:
✅Wash your hands using soap and running water
⛔Avoid direct handling of dead bats, monkeys etc
⛔Avoid physical contact with anyone with undiagnosed symptoms
📜Advisory
https://ncdc.gov.ng/news/423/public-health-advisory-following-declaration-of-ebola-virus-disease-outbreak-in-uganda
ДжоПи:
Как найти вопрос, на который не знаешь ответа?
Это как найти шапку, которую уже надел,
Но забыл об этом.
Как пристроить ответ, на который не задан вопрос?
(У меня их столько за жизнь заготовлено.)
Как снежков налепить в одиночку,
а не в кого бросить.
Вот прибрался в комнате,
и день прошёл.
А план не изменился.
#bitnev#стихи#takeresponsibility