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

Резултати

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

Пребарај: #pl

当前筛选 #pl清除筛选
CHELSEA NEWS 🗞️ 🔵

@Chelsea_fc_worldwide · Post #177100 · 04.05.2026 г., 19:31

Jesse Derry was taken to hospital as a precaution following his first-half substitution during today’s #PL game against Nottingham Forest. Jesse is conscious, talking and undergoing precautionary checks. We wish him a speedy recovery and thank the medical staff for their swift response.

Hashtags

CHELSEA NEWS 🗞️ 🔵

@Chelsea_fc_worldwide · Post #176606 · 07.04.2026 г., 18:03

Our Blues. Our TOTS Nominees. 🤝🏻 Vote now for your EASportsFC #PL Team of the Season! 💙 🗳️ Vote here - https://x.ea.com/88867

Hashtags

Manchester United⚽💯

@manchester_utdfc · Post #114538 · 08.04.2026 г., 11:28

Steve Holland: “Our last game, Bournemouth to Leeds, is a #PL record, I think, in terms of time between games. “So the gap has been as big as you can have really. I think we felt it was important to get the whole group together again, and really focus on finishing the season well. “I think this is the PERFECT venue for that, really.” Steve Holland: “I think the language we should be using as this club is to finish as CLOSE as we possibly can to the top [this season]. “I don’t know how possible that is, but that has to be the challenge always: to get as close as we possibly CAN to the top...” [MU]

Hashtags

Manchester United⚽💯

@manchester_utdfc · Post #114517 · 07.04.2026 г., 08:18

Bruno Fernandes on matching Cristiano Ronaldo’s #PL POTM record: “It’s always good company. We know when records are there, his name will always be around. “It’s a HUGE honour and privilege to be close to him.” 🇵🇹❤️

Hashtags

Manchester United⚽💯

@manchester_utdfc · Post #113990 · 01.03.2026 г., 21:19

Bruno Fernandes has to secure 8 assists in 10 games to break the #PL record for most assists in a season (20). Can he do it…? 🇵🇹 📥@Manchester_Utdfc

Hashtags

ПретходнаСтраница 1 од 5Следна