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

Резултати

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

Пребарај: #internationalaffairs

当前筛选 #internationalaffairs清除筛选

🎙 Russia's Foreign Minister Sergey Lavrov’s interview with Marina Kim for the New World project (Moscow, November 14, 2024) Key talking points: #InternationalAffairs • Our main task now is to achieve all the goals formulated by President Vladimir Putin. You are aware of the West’s expectations. They are speculating about stopping the hostilities at a certain line and coordinating a truce, so that 10 years from now they will decide who Crimea and Donbass belong to. This is coffee cup reading. I won’t engage in it. We have our tasks, and we will fulfil them. • Our job is to assert and promote Russia’s interests in keeping with its Constitution as well as the objectives defined by President Vladimir Putin. This goes beyond Ukraine and applies to Russia’s Foreign Policy Concept in general. #USA • Washington can’t allow Russia to prove that it is a strong player and undermine the West’s reputation. They don’t care about Ukraine. They only care about their reputation. They decided that Ukraine should have a government they like and didn’t expect anyone to protest. Russia? It’s a big country but it must be brought down a peg. That is what this is about rather than the future of the Ukrainian people. They don’t care about people. • Sanctions have been imposed on over half of the world’s countries, even if they are not as drastic as those that have been adopted against Russia, the Democratic People’s Republic of Korea, Iran and Venezuela. The real reason behind the West’s current rage is that China is rapidly and confidently surging ahead of the United States. • We can see through what the Americans want. Sitting somewhere overseas, they believe that they are beyond the reach, while leaving it to Europe to overcome the challenges they face in terms of encouraging and arming Ukraine to fight Russia, as well as footing the bill for the Middle East tragedy. #Eurasia4You • God gave us one continent, and we share it. This continent possesses immense and, in fact, the biggest natural resources, while several millennia-old civilisations inhabit it. Failing to benefit from these competitive advantages would be a mistake. This is what the idea of building a Greater Eurasian Partnership is all about, and the EAEU, SCO and ASEAN have already taken the first steps in this direction. We are establishing ties and promoting dialogue. If we succeed in fulfilling the plans we have, the Greater Eurasian Partnership will offer a solid foundation and serve as an economic and transport backbone for what President Vladimir Putin called a new Eurasian security architecture. • There is a clear understanding that the Eurasian security architecture, just like the Greater Eurasian Partnership, must be open to all countries and continents, including Eurasia’s western part, even if so far the latter has been trying, as if by inertia, to ensure its interests within a Euro-Atlantic security concept instead of opting for the Eurasian framework, which would be natural and reasonable, considering the geography factor. This is their way of saying that they do not intend to do anything without the United States. #BRICS 🌐 BRICS is about the new world order that is based on the main principle of the UN Charter – the sovereign equality of states. • BRICS has no intention of dividing the world. It wants to bring together countries that desire closer relations so that they can live on the land they got from God and their ancestors just as they used to, as great civilisations. #Africa 🌍 Decolonisation has taken place, in a broad sense. But being able to actually manage one’s freedom and resources is a different story. This is where neo-colonialism comes to the fore. • The First Ministerial Conference of the Russia-Africa Partnership Forum in Sochi, and the Russia-Africa Summit in St Petersburg in 2023 clearly put into perspective the trends that could be called Africa’s second awakening.