Подразумеваемые неймспейсы или неявные пакеты.
Этот функционал добавлен в 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
#from#beautiful
A mother and a child on a wooden horse photo, in the style of gritty urban realism, new american documentary photography, mixed media installations, cheyenne art, rural life depictions, colorized, suburban ennui capturer --ar 103:128 --v 6.0
✅pitpeterssen _Midjourney v6.0
🚀Boost this Channel
@ai_artz🌿
#from#beautiful
Beautiful indian woman flying up in the sky with her aircraft chair, clouds moving in full speed, woman streching her hands on clouds, her hair also flying in speed, minimal, shot with Sony Alpha with wide angle lens, 16k, candid, aperture F1.2, full detail shot, dramatic lighting, --ar 16:9
✅ Vinaysaya _Discord
@ai_artz
#from#beautiful
Portrait and fashion photography: a combination of renaissance costumes and snowflakes, texturing, ::elegant clothes worn by the most beautiful women, a woman with a wonderful face and expressive eyes, beautiful delicate makeup, the highest quality, translucent floral fabrics, simple and aesthetic hairstyles, dynamic poses, neutral interesting dark background, award winning fashion photography, photorealistic, bright, elegant, golden ratio, elite, highly detailed, color triad, dynamic composition, ultra resolution, ultra wide shot, digital art, world made of light, soft lighting, unreal engine, depth of field 8k, full hd photo, HDR, high resolution photography, macro photography, beautiful highlights, zbrush art, photoshop, studio setting, simple, neutral, grainy, matte, fashion style :: Canon EOS 5D Mark IV EFL 100mm, f /1.4, ISO 50, 1/100 sec, Eye Sharpness, RAW, v4 - a r 2:3 - 800 sec, Chaos 49
✅ Adora _Discord
@ai_artz
#from#beautiful
An underwater urbex guerilla garden with old cars on the shoal underwater ::directional light, cinematic, alcohol ink and cinematic, saudek and sorayama ::hyperrealistic --ar 3:2 --q 2 --upbeta --s 750 --v 5.1
✅ Prima Demonessa _Discord
Join us for more @ai_artz
#from#beautiful
Gouache painting of a book-nook diorama of a cryptid conservatory, has incredible attention to detail, intricate, highly detailed, fantastic realism, fantasy, magical, led lights, --q 2 --s 750
✅ Adriann _Discord
@ai_artz
#from#beautiful
Photography of the living room of a huge hotel on Mars, futuristic Hotel on Mars furnished in japanes style, 8k, photo realistic, beautiful japanese design, welcoming Hotel, ultra realistic, ultra detaile
✅ Max05 _Discord
@ai_artz