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

Пребарај: #binaries

当前筛选 #binaries清除筛选
Universe Mysteries 🪐

@cosmomyst · Post #621 · 14.01.2026 г., 12:21

🪐 Deep in the constellation Draco lies the pulsar PSR J2222−0137, a unique spinning neutron star about 900 light-years from Earth that forms a binary system with a faint white dwarf. PSR J2222−0137 spins once every 33 milliseconds, and its partner is one of the coolest known white dwarfs, so cold that its surface may be made of crystallized oxygen—offering a rare glimpse of two extreme stellar remnants circling each other in quiet cosmic partnership. ✨ #pulsars⚡#binaries⚡#neutronstars⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels ​

Universe Mysteries 🪐

@cosmomyst · Post #450 · 23.10.2025 г., 22:21

🪐 The star AR Scorpii, located about 380 light-years away in the constellation Scorpius, is an unusual binary system where a rapidly spinning white dwarf blasts powerful beams of energy at its red dwarf companion. Unlike typical stars, AR Scorpii pulses in visible light and radio waves every two minutes as its magnetic field accelerates particles, making it the first known "white dwarf pulsar" in our galaxy. ✨ #unusualstars⚡#binaries⚡#pulsars⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels ​

Universe Mysteries 🪐

@cosmomyst · Post #431 · 16.10.2025 г., 12:21

🪐 The star VFTS 352, located in the Tarantula Nebula about 160,000 light-years away, is actually two massive stars orbiting each other so closely that their outer layers touch—creating a rare "overcontact binary." This unusual system is on the verge of merging, and both stars are so hot and bright that their shared atmosphere fuses them together, making VFTS 352 one of the most extreme examples of stellar partnership ever found. ✨ #unusualstars⚡#binaries⚡#TarantulaNebula⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels ​

Universe Mysteries 🪐

@cosmomyst · Post #60 · 02.08.2025 г., 03:11

🪐 The exoplanet Kepler-16b orbits not one, but two stars, forming a real-life counterpart to a Tatooine-like world in the constellation Cygnus. This Saturn-sized planet experiences double sunrises and sunsets as it circles both its orange and red dwarf hosts, creating a celestial theater found nowhere in our own solar system. ✨ #exoplanets⚡#binaries⚡#kepler⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries