TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #197 · 4 јан.

Подразумеваемые неймспейсы или неявные пакеты. Этот функционал добавлен в 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

Hashtags

Резултати

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

Пребарај: #habitable

当前筛选 #habitable清除筛选
Interesting Planet 🌍

@interesting_planet_facts · Post #744 · 14.09.2025 г., 00:22

🌎 In 2016, astronomers discovered TRAPPIST-1, a star system 40 light-years away with seven Earth-sized planets. Three orbit in the "habitable zone," where liquid water could exist—making it one of the most promising sites for searching for alien life beyond our solar system. ✨ #astronomy⚡#exoplanets⚡#habitable 👉subscribe Interesting Planet ​

Universe Mysteries 🪐

@cosmomyst · Post #173 · 22.08.2025 г., 16:11

🪐 Astronomers have identified the super-Earth exoplanet HD 40307g, located about 42 light-years away in the constellation Pictor, as a promising candidate for life because it may orbit within its star’s habitable zone—the region where temperatures could allow liquid water on the surface. With a mass at least seven times that of Earth and the right distance from its parent star, HD 40307g offers a real-world example of a potentially life-friendly world beyond our solar system. ✨ #exoplanets⚡#habitable⚡#universe⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#cosmos⚡#space 👉subscribe Universe Mysteries ​

Universe Mysteries 🪐

@cosmomyst · Post #125 · 13.08.2025 г., 03:11

🪐 Orbiting the faint red star TOI-700, about 100 light-years from Earth, the exoplanet TOI-700 d sits within its star's "habitable zone"—the region around a star where temperatures might allow liquid water to exist. With a size just slightly smaller than Earth and a surface that could potentially support mild climates, TOI-700 d stands out as a real-world candidate in our search for places beyond our solar system where life could survive. ✨ #exoplanets⚡#habitable⚡#life⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #725 · 28.03.2026 г., 22:21

🪐 In the TRAPPIST-1 system, about 40 light-years away, seven Earth-sized exoplanets orbit a cool, dim star, and at least three of them lie in the star’s “habitable zone”—the region where temperatures might allow liquid water to exist on their surfaces. This cluster of small worlds makes TRAPPIST-1 one of the top real candidates in the search for places where life could exist beyond our solar system. ✨ #TRAPPIST1⚡#exoplanets⚡#habitable⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels ​