Подразумеваемые неймспейсы или неявные пакеты.
Этот функционал добавлен в 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
🪐 The giant planet WASP-96b, discovered about 1,150 light-years from Earth, made headlines when the James Webb Space Telescope detected a clear signature of water vapor in its scorching atmosphere. Unlike planets in our solar system, WASP-96b has no clouds and its skies allow starlight to pass straight through, giving scientists an unusually direct view of a giant planet's steamy, alien air. ✨
#giantplanets⚡#exoplanets⚡#atmosphere⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The giant exoplanet HD 209458b, located about 150 light-years from Earth in the constellation Pegasus, is known as "Osiris" and was the first planet beyond our solar system found to have an atmosphere. As it orbits extremely close to its star, its atmosphere is heated and blown away by stellar radiation, creating a long tail of escaping gas much like a comet streaking through space. ✨
#giantplanets⚡#exoplanets⚡#atmosphere⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 Exoplanet HAT-P-7b, a giant planet about 1,040 light-years away in the constellation Cygnus, experiences wild weather that causes its thick clouds to constantly switch sides. Powerful winds, driven by the planet’s close orbit to its star, move clouds of vaporized minerals from one hemisphere to the other—a phenomenon never seen anywhere else in the universe. ✨
#giantplanets⚡#exoplanets⚡#weather⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The giant planet HD 189733b, located about 64 light-years away in the constellation Vulpecula, is famous for having blue clouds made of molten glass that whip through its atmosphere at wind speeds over 7,000 kilometers per hour. Unlike Earth's gentle blue sky, the blue color of HD 189733b comes from silicate particles that scatter blue light, creating a world where glass rain falls sideways in scorching, stormy gales. ✨
#exoplanets⚡#giantplanets⚡#atmospheres⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 Some of the most mysterious worlds in our galaxy are rogue planets like CFBDSIR J214947.2-040308.9, a giant planet drifting alone in interstellar space without a star to orbit. Detected about 130 light-years from Earth, this lonely world glows with leftover heat from its birth and is studied in infrared light, revealing that even without a sun, planets can wander the dark, silent stretches between stars. ✨
#rogueplanets⚡#interstellar⚡#giantplanets⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 Exoplanet WASP-12b, about 1,400 light-years away in the constellation Auriga, is a giant planet so close to its star that its atmosphere is being stripped away, creating a glowing, comet-like tail. This tidal distortion makes WASP-12b egg-shaped rather than round, showing how extreme gravity can reshape giant planets when they orbit near their stars. ✨
#giantplanets⚡#exoplanet⚡#gravity⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The giant exoplanet HAT-P-32b, about 950 light-years away in the constellation Andromeda, is so puffed up that it's nearly twice the diameter of Jupiter but only a fraction as dense—almost like a balloon made of hot gas. Its incredibly low density means a bathtub big enough for HAT-P-32b would float it, revealing how giant planets can take on bizarre, bloated forms far beyond the familiar giants of our own solar system. ✨
#exoplanets⚡#giantplanets⚡#hatp32b⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The enormous exoplanet HD 100546 b, located about 320 light-years away in the constellation Musca, is one of the youngest giant planets ever observed—less than 10 million years old. Still surrounded by a swirling disk of gas and dust, this massive world is so new that scientists have caught it in the act of forming, offering a rare glimpse at how giant planets grow while carving out gaps in their birth disks. ✨
#giantplanets⚡#exoplanets⚡#planetformation⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 Saturn is so massive and spins so quickly—completing a rotation in just over 10 hours—that its fast spin causes the planet to flatten at the poles and bulge at the equator. This makes Saturn wider across the middle than from top to bottom, giving it a distinct squashed-ball appearance unlike most other planets in the solar system. ✨
#Saturn⚡#giantplanets⚡#rotation⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 Jupiter’s Great Red Spot is the largest storm in the solar system—a swirling oval bigger than Earth itself that has raged for at least 350 years. This ancient storm sits high in Jupiter’s atmosphere and its swirling winds reach speeds of over 430 kilometers per hour, offering a glimpse into the extreme weather that can brew on giant planets. ✨
#Jupiter⚡#storms⚡#giantplanets⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 Neptune’s internal heat keeps this giant planet surprisingly active, releasing more than twice as much energy as it receives from the Sun. This extra energy drives Neptune’s fierce storms and the fastest winds in the solar system, revealing that giant planets can be turbulent worlds even in the freezing dark far from their star. ✨
#Neptune⚡#giantplanets⚡#storms⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The giant planet Neptune, about 17 times heavier than Earth, has the fastest winds in the solar system, reaching speeds over 2,000 kilometers per hour. These icy, supersonic winds zip through Neptune's blue methane clouds, creating enormous, swirling storms that can dwarf our entire planet. ✨
#Neptune⚡#giantplanets⚡#storms⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries