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

Резултати

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

Пребарај: #disappearance

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

@interesting_planet_facts · Post #786 · 20.09.2025 г., 12:11

🌎 The disappearance of the Sodder children in 1945 remains unsolved. Five siblings vanished after a house fire in Fayetteville, West Virginia. Investigators found no remains in the ash, and sightings were later reported but never verified. A billboard seeking answers stood along Route 16 for decades. ✨ #history⚡#disappearance⚡#mystery 👉subscribe Interesting Planet ​

Interesting Planet 🌍

@interesting_planet_facts · Post #991 · 31.10.2025 г., 12:11

🌎 In 2009, French aircraft Air France Flight 447 disappeared over the Atlantic during a flight from Rio de Janeiro to Paris. All 228 people on board died. The plane's wreckage was not found for nearly two years, when deep-sea searches located the main debris field at a depth of 3,900 meters. ✨ #aviation⚡#disappearance⚡#ocean 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #720 · 10.09.2025 г., 00:22

🌎 In 1815, the British brig HMS Rosalie was found abandoned and drifting near the Bahamas. The ship’s sails were set, and cargo untouched, but not a single crew member was found onboard. Official records note that the ship’s logbook and personal belongings were still present when discovered. ✨ #disappearance⚡#maritime⚡#mystery 👉subscribe Interesting Planet ​

Interesting Planet 🌍

@interesting_planet_facts · Post #884 · 09.10.2025 г., 20:11

🌎 In 1973, Australian pilot Frederick Valentich disappeared while flying a Cessna 182L over Bass Strait. During radio contact, he reported a strange, unidentified craft circling his plane before transmission was lost. Despite a large search, neither Valentich nor his aircraft were ever found. ✨ #disappearance⚡#aviation⚡#australia 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #657 · 30.08.2025 г., 16:22

🌎 In 1872, the Mary Celeste was found adrift in the Atlantic Ocean—its crew vanished without a trace, leaving food, cargo, and the ship untouched. This unsolved maritime mystery has puzzled historians ever since. ✨ #disappearance⚡#ship⚡#mystery 👉subscribe Interesting Planet ​

Interesting Planet 🌍

@interesting_planet_facts · Post #1315 · 25.02.2026 г., 12:11

🌎 In 1925, British explorer Percy Fawcett vanished in Brazil's Amazon rainforest while searching for the lost city of "Z." Fawcett, his son, and a companion were last seen near the Upper Xingu River. Despite dozens of rescue missions over decades, no confirmed trace of the expedition was ever found. ✨ #amazon⚡#disappearance⚡#exploration 👉subscribe Interesting Planet 👉more Channels ​