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

Резултати

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

Пребарај: #aden

当前筛选 #aden清除筛选
Reuters: World

@reutersworldchannel · Post #149187 · 10.10.2021 г., 17:23

WARNING: GRAPHIC CONTENT: Car bomb in Yemen's Aden leaves fatalities A car bomb targeting the governor's convoy shook Yemen's southern port city of Aden, killing several people #News#Reuters#Yemen#CarBomb#Aden Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Addis Standard

@addisstandardeng · Post #21285 · 03.02.2026 г., 06:35

#Yemen Agriculture ministry condemns #Eritrean & #Somali attacks on Yemeni Fishermen The Agriculture, Fisheries and Water Resources Ministry strongly condemned the criminal attacks and repeated violations targeting Yemeni fishermen in the #Red_Sea and the Gulf of #Aden by the Eritrean authorities and the authorities of the Somali region, describing them as a blatant violation of international, humanitarian, and maritime laws, norms, and conventions. In a statement received by the Yemeni News Agency (Saba), the Ministry explained that Eritrean forces carried out a direct armed attack using live ammunition against civilian Yemeni fishermen within the territorial waters of the Republic of Yemen in the Red Sea, resulting in deaths and injuries, as well as the detention of a number of fishermen who were forcibly taken away. The Ministry considered these actions a dangerous escalation that threatens the safety, security of fishermen, targets their livelihoods and ..... https://saba.ye/en/news3639829.htm

Addis Standard

@addisstandardeng · Post #21699 · 13.03.2026 г., 06:55

#Somalia warns against any #Israeli base plans on #Somaliland Somalia has warned that its territory cannot be used as a launching pad for military operations, after two media reports that said Israel is planning to establish a military base in the breakaway region of Somaliland, directly across the Gulf of #Aden from #Yemen. “Somalia does not want to see its territory pulled into external confrontations or used in ways that could further destabilise an already sensitive region,” Ali Omar, Somalia’s state minister for foreign affairs, told Al Jazeera on Thursday. The warning from #Mogadishu comes after #US outlet Bloomberg and Sweden’s public radio Ekot reported this week about Israeli plans for a military installation near the strategic port city of #Berbera on the Gulf of Aden. The reports come as the US Israeli war on Iran edges towards its second week, with the Strait of Hormuz effectively closed...... https://www.aljazeera.com/news/2026/3/12/somalia-warns-against-any-israeli-base-plans-on-somaliland