Подразумеваемые неймспейсы или неявные пакеты.
Этот функционал добавлен в 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
6️⃣5️⃣years since Yuri Gagarin’s historic space feat!
🚀On April 12, 1961, the Vostok launch vehicle lifted off from the Baikonur Cosmodrome. This momentous event marked the culmination of the efforts of millions of Soviet citizens – design engineers, scientists, military pilots, doctors, specialists across a wide range of fields, and entire branches of industry. Inside the cramped cabin of the crewed spacecraft was Senior Lieutenant Yuri Gagarin.
At 9:07 am, the four metal arms holding the 287-tonne rocket retracted, and Vostok began its lift-off. It was at that very moment that Gagarin’s famous “#POYEKHALI!”(*Let’s go!) rang out over the radio.
At 9:12 am, the spacecraft separated from the launch vehicle and entered the Earth's orbit. Its speed reached 28,260 kilometres per hour – nearly 8 kilometres per second. Never before had a human travelled so fast.
🎙Just as the spacecraft reached Earth's orbit, Yuri Levitan – the USSR’s iconic radio announcer – solemnly declared to the world:
This is Moscow speaking! The time in Moscow is 10:02 am. We are broadcasting a TASS report on the first human flight into outer space.
On April 12, 1961, the Soviet Union launched into orbit around the Earth the world’s first spacecraft-satellite, Vostok, with a man on board.
The pilot-cosmonaut is a citizen of the USSR, Air Force Major Yuri Gagarin (the extraordinary rank was conferred by Order No. 77 of the USSR Minister of Defence, dated April 12, 1961).
While in orbit, Gagarin recorded his observations and transmitted them back to Earth. Before him lay the planet as no one had ever seen it before: the curve of the horizon, the luminous blue edge of the atmosphere, coastlines, mountain ranges, vast landmasses – all set against the bottomless black void of space.
Almost 90 minutes into the flight, the spacecraft began its descent. At that moment, a highly dangerous emergency arose: the descent module failed to separate immediately from the equipment module. However, as the spacecraft re-entered the dense layers of the atmosphere, the connecting cables between the two sections burned through due to friction, and the descent continued.
At 10:42 am, at an altitude of 7 km, the cosmonaut ejected.
At 10:53 am, Yuri Gagarin landed safely in a field near the city of Engels, around 4 km from the present-day bank of the Volga.
On April 14, 1961, by Decree No. 251/22 of the Presidium of the Supreme Soviet of the USSR, Yuri Gagarin was awarded the title Hero of the Soviet Union, together with the Order of Lenin and the Gold Star medal.
Two days later, the people of Moscow welcomed the space traveller to the Soviet capital with flowers and celebratory banners. By the end of April, Earth’s first cosmonaut embarked on an international tour to share what he had witnessed with people around the world. In the two years following this historic event, Yuri Gagarin visited more than 30 countries, where he was honoured as a true hero. The tour became unofficially known as the “Mission of Peace”.
***
1️⃣0️⃣6️⃣minutes of Yuri Gagarin's flight changed the course of world history.
Just 16 years after the most devastating and bloodiest war in human history, the Soviet people achieved what had only recently seemed impossible – opening the way to space for all humankind.
***
💬 As President Vladimir Putin noted in his message to the participants in the first Russian Space Forum on April 9, 2026:
Yuri Gagarin's spaceflight became one of the great events of the 20th century and opened a new era in the history of human civilisation.
We are sincerely proud of several generations of talented scientists, designers, cosmonauts, military personnel and civilian specialists who stood at the origins of the national space programme and wrote bright, heroic pages in the chronicle of its victories and achievements.
🇺🇳 Since 2011, April 12 has been observed as the International Day of Human Space Flight, proclaimed by the UN General Assembly under resolution A/RES/65/271 in honour of Yuri Gagarin’s legendary mission.
#Gagarin65#FirstInSpace
6️⃣5️⃣years since Yuri Gagarin’s historic space feat!
🚀On April 12, 1961, the Vostok launch vehicle lifted off from the Baikonur Cosmodrome. This momentous event marked the culmination of the efforts of millions of Soviet citizens – design engineers, scientists, military pilots, doctors, specialists across a wide range of fields, and entire branches of industry. Inside the cramped cabin of the crewed spacecraft was Senior Lieutenant Yuri Gagarin.
At 9:07 am, the four metal arms holding the 287-tonne rocket retracted, and Vostok began its lift-off. It was at that very moment that Gagarin’s famous “#POYEKHALI!”(*Let’s go!) rang out over the radio.
At 9:12 am, the spacecraft separated from the launch vehicle and entered the Earth's orbit. Its speed reached 28,260 kilometres per hour – nearly 8 kilometres per second. Never before had a human travelled so fast.
🎙Just as the spacecraft reached Earth's orbit, Yuri Levitan – the USSR’s iconic radio announcer – solemnly declared to the world:
This is Moscow speaking! The time in Moscow is 10:02 am. We are broadcasting a TASS report on the first human flight into outer space.
On April 12, 1961, the Soviet Union launched into orbit around the Earth the world’s first spacecraft-satellite, Vostok, with a man on board.
The pilot-cosmonaut is a citizen of the USSR, Air Force Major Yuri Gagarin (the extraordinary rank was conferred by Order No. 77 of the USSR Minister of Defence, dated April 12, 1961).
While in orbit, Gagarin recorded his observations and transmitted them back to Earth. Before him lay the planet as no one had ever seen it before: the curve of the horizon, the luminous blue edge of the atmosphere, coastlines, mountain ranges, vast landmasses – all set against the bottomless black void of space.
Almost 90 minutes into the flight, the spacecraft began its descent. At that moment, a highly dangerous emergency arose: the descent module failed to separate immediately from the equipment module. However, as the spacecraft re-entered the dense layers of the atmosphere, the connecting cables between the two sections burned through due to friction, and the descent continued.
At 10:42 am, at an altitude of 7 km, the cosmonaut ejected.
At 10:53 am, Yuri Gagarin landed safely in a field near the city of Engels, around 4 km from the present-day bank of the Volga.
On April 14, 1961, by Decree No. 251/22 of the Presidium of the Supreme Soviet of the USSR, Yuri Gagarin was awarded the title Hero of the Soviet Union, together with the Order of Lenin and the Gold Star medal.
Two days later, the people of Moscow welcomed the space traveller to the Soviet capital with flowers and celebratory banners. By the end of April, Earth’s first cosmonaut embarked on an international tour to share what he had witnessed with people around the world. In the two years following this historic event, Yuri Gagarin visited more than 30 countries, where he was honoured as a true hero. The tour became unofficially known as the “Mission of Peace”.
***
1️⃣0️⃣6️⃣minutes of Yuri Gagarin's flight changed the course of world history.
Just 16 years after the most devastating and bloodiest war in human history, the Soviet people achieved what had only recently seemed impossible – opening the way to space for all humankind.
***
💬 As President Vladimir Putin noted in his message to the participants in the first Russian Space Forum on April 9, 2026:
Yuri Gagarin's spaceflight became one of the great events of the 20th century and opened a new era in the history of human civilisation.
We are sincerely proud of several generations of talented scientists, designers, cosmonauts, military personnel and civilian specialists who stood at the origins of the national space programme and wrote bright, heroic pages in the chronicle of its victories and achievements.
🇺🇳 Since 2011, April 12 has been observed as the International Day of Human Space Flight, proclaimed by the UN General Assembly under resolution A/RES/65/271 in honour of Yuri Gagarin’s legendary mission.
#Gagarin65#FirstInSpace
6️⃣5️⃣years since Yuri Gagarin’s historic space feat!
🚀On April 12, 1961, the Vostok launch vehicle lifted off from the Baikonur Cosmodrome. This momentous event marked the culmination of the efforts of millions of Soviet citizens – design engineers, scientists, military pilots, doctors, specialists across a wide range of fields, and entire branches of industry. Inside the cramped cabin of the crewed spacecraft was Senior Lieutenant Yuri Gagarin.
At 9:07 am, the four metal arms holding the 287-tonne rocket retracted, and Vostok began its lift-off. It was at that very moment that Gagarin’s famous “#POYEKHALI!”(*Let’s go!) rang out over the radio.
At 9:12 am, the spacecraft separated from the launch vehicle and entered the Earth's orbit. Its speed reached 28,260 kilometres per hour – nearly 8 kilometres per second. Never before had a human travelled so fast.
🎙Just as the spacecraft reached Earth's orbit, Yuri Levitan – the USSR’s iconic radio announcer – solemnly declared to the world:
This is Moscow speaking! The time in Moscow is 10:02 am. We are broadcasting a TASS report on the first human flight into outer space.
On April 12, 1961, the Soviet Union launched into orbit around the Earth the world’s first spacecraft-satellite, Vostok, with a man on board.
The pilot-cosmonaut is a citizen of the USSR, Air Force Major Yuri Gagarin (the extraordinary rank was conferred by Order No. 77 of the USSR Minister of Defence, dated April 12, 1961).
While in orbit, Gagarin recorded his observations and transmitted them back to Earth. Before him lay the planet as no one had ever seen it before: the curve of the horizon, the luminous blue edge of the atmosphere, coastlines, mountain ranges, vast landmasses – all set against the bottomless black void of space.
Almost 90 minutes into the flight, the spacecraft began its descent. At that moment, a highly dangerous emergency arose: the descent module failed to separate immediately from the equipment module. However, as the spacecraft re-entered the dense layers of the atmosphere, the connecting cables between the two sections burned through due to friction, and the descent continued.
At 10:42 am, at an altitude of 7 km, the cosmonaut ejected.
At 10:53 am, Yuri Gagarin landed safely in a field near the city of Engels, around 4 km from the present-day bank of the Volga.
On April 14, 1961, by Decree No. 251/22 of the Presidium of the Supreme Soviet of the USSR, Yuri Gagarin was awarded the title Hero of the Soviet Union, together with the Order of Lenin and the Gold Star medal.
Two days later, the people of Moscow welcomed the space traveller to the Soviet capital with flowers and celebratory banners. By the end of April, Earth’s first cosmonaut embarked on an international tour to share what he had witnessed with people around the world. In the two years following this historic event, Yuri Gagarin visited more than 30 countries, where he was honoured as a true hero. The tour became unofficially known as the “Mission of Peace”.
***
1️⃣0️⃣6️⃣minutes of Yuri Gagarin's flight changed the course of world history.
Just 16 years after the most devastating and bloodiest war in human history, the Soviet people achieved what had only recently seemed impossible – opening the way to space for all humankind.
***
💬 As President Vladimir Putin noted in his message to the participants in the first Russian Space Forum on April 9, 2026:
Yuri Gagarin's spaceflight became one of the great events of the 20th century and opened a new era in the history of human civilisation.
We are sincerely proud of several generations of talented scientists, designers, cosmonauts, military personnel and civilian specialists who stood at the origins of the national space programme and wrote bright, heroic pages in the chronicle of its victories and achievements.
🇺🇳 Since 2011, April 12 has been observed as the International Day of Human Space Flight, proclaimed by the UN General Assembly under resolution A/RES/65/271 in honour of Yuri Gagarin’s legendary mission.
#Gagarin65#FirstInSpace
6️⃣5️⃣years since Yuri Gagarin’s historic space feat!
🚀On April 12, 1961, the Vostok launch vehicle lifted off from the Baikonur Cosmodrome. This momentous event marked the culmination of the efforts of millions of Soviet citizens – design engineers, scientists, military pilots, doctors, specialists across a wide range of fields, and entire branches of industry. Inside the cramped cabin of the crewed spacecraft was Senior Lieutenant Yuri Gagarin.
At 9:07 am, the four metal arms holding the 287-tonne rocket retracted, and Vostok began its lift-off. It was at that very moment that Gagarin’s famous “#POYEKHALI!”(*Let’s go!) rang out over the radio.
At 9:12 am, the spacecraft separated from the launch vehicle and entered the Earth's orbit. Its speed reached 28,260 kilometres per hour – nearly 8 kilometres per second. Never before had a human travelled so fast.
🎙Just as the spacecraft reached Earth's orbit, Yuri Levitan – the USSR’s iconic radio announcer – solemnly declared to the world:
This is Moscow speaking! The time in Moscow is 10:02 am. We are broadcasting a TASS report on the first human flight into outer space.
On April 12, 1961, the Soviet Union launched into orbit around the Earth the world’s first spacecraft-satellite, Vostok, with a man on board.
The pilot-cosmonaut is a citizen of the USSR, Air Force Major Yuri Gagarin (the extraordinary rank was conferred by Order No. 77 of the USSR Minister of Defence, dated April 12, 1961).
While in orbit, Gagarin recorded his observations and transmitted them back to Earth. Before him lay the planet as no one had ever seen it before: the curve of the horizon, the luminous blue edge of the atmosphere, coastlines, mountain ranges, vast landmasses – all set against the bottomless black void of space.
Almost 90 minutes into the flight, the spacecraft began its descent. At that moment, a highly dangerous emergency arose: the descent module failed to separate immediately from the equipment module. However, as the spacecraft re-entered the dense layers of the atmosphere, the connecting cables between the two sections burned through due to friction, and the descent continued.
At 10:42 am, at an altitude of 7 km, the cosmonaut ejected.
At 10:53 am, Yuri Gagarin landed safely in a field near the city of Engels, around 4 km from the present-day bank of the Volga.
On April 14, 1961, by Decree No. 251/22 of the Presidium of the Supreme Soviet of the USSR, Yuri Gagarin was awarded the title Hero of the Soviet Union, together with the Order of Lenin and the Gold Star medal.
Two days later, the people of Moscow welcomed the space traveller to the Soviet capital with flowers and celebratory banners. By the end of April, Earth’s first cosmonaut embarked on an international tour to share what he had witnessed with people around the world. In the two years following this historic event, Yuri Gagarin visited more than 30 countries, where he was honoured as a true hero. The tour became unofficially known as the “Mission of Peace”.
***
1️⃣0️⃣6️⃣minutes of Yuri Gagarin's flight changed the course of world history.
Just 16 years after the most devastating and bloodiest war in human history, the Soviet people achieved what had only recently seemed impossible – opening the way to space for all humankind.
***
💬 As President Vladimir Putin noted in his message to the participants in the first Russian Space Forum on April 9, 2026:
Yuri Gagarin's spaceflight became one of the great events of the 20th century and opened a new era in the history of human civilisation.
We are sincerely proud of several generations of talented scientists, designers, cosmonauts, military personnel and civilian specialists who stood at the origins of the national space programme and wrote bright, heroic pages in the chronicle of its victories and achievements.
🇺🇳 Since 2011, April 12 has been observed as the International Day of Human Space Flight, proclaimed by the UN General Assembly under resolution A/RES/65/271 in honour of Yuri Gagarin’s legendary mission.
#Gagarin65#FirstInSpace
6️⃣5️⃣years since Yuri Gagarin’s historic space feat!
🚀On April 12, 1961, the Vostok launch vehicle lifted off from the Baikonur Cosmodrome. This momentous event marked the culmination of the efforts of millions of Soviet citizens – design engineers, scientists, military pilots, doctors, specialists across a wide range of fields, and entire branches of industry. Inside the cramped cabin of the crewed spacecraft was Senior Lieutenant Yuri Gagarin.
At 9:07 am, the four metal arms holding the 287-tonne rocket retracted, and Vostok began its lift-off. It was at that very moment that Gagarin’s famous “#POYEKHALI!”(*Let’s go!) rang out over the radio.
At 9:12 am, the spacecraft separated from the launch vehicle and entered the Earth's orbit. Its speed reached 28,260 kilometres per hour – nearly 8 kilometres per second. Never before had a human travelled so fast.
🎙Just as the spacecraft reached Earth's orbit, Yuri Levitan – the USSR’s iconic radio announcer – solemnly declared to the world:
This is Moscow speaking! The time in Moscow is 10:02 am. We are broadcasting a TASS report on the first human flight into outer space.
On April 12, 1961, the Soviet Union launched into orbit around the Earth the world’s first spacecraft-satellite, Vostok, with a man on board.
The pilot-cosmonaut is a citizen of the USSR, Air Force Major Yuri Gagarin (the extraordinary rank was conferred by Order No. 77 of the USSR Minister of Defence, dated April 12, 1961).
While in orbit, Gagarin recorded his observations and transmitted them back to Earth. Before him lay the planet as no one had ever seen it before: the curve of the horizon, the luminous blue edge of the atmosphere, coastlines, mountain ranges, vast landmasses – all set against the bottomless black void of space.
Almost 90 minutes into the flight, the spacecraft began its descent. At that moment, a highly dangerous emergency arose: the descent module failed to separate immediately from the equipment module. However, as the spacecraft re-entered the dense layers of the atmosphere, the connecting cables between the two sections burned through due to friction, and the descent continued.
At 10:42 am, at an altitude of 7 km, the cosmonaut ejected.
At 10:53 am, Yuri Gagarin landed safely in a field near the city of Engels, around 4 km from the present-day bank of the Volga.
On April 14, 1961, by Decree No. 251/22 of the Presidium of the Supreme Soviet of the USSR, Yuri Gagarin was awarded the title Hero of the Soviet Union, together with the Order of Lenin and the Gold Star medal.
Two days later, the people of Moscow welcomed the space traveller to the Soviet capital with flowers and celebratory banners. By the end of April, Earth’s first cosmonaut embarked on an international tour to share what he had witnessed with people around the world. In the two years following this historic event, Yuri Gagarin visited more than 30 countries, where he was honoured as a true hero. The tour became unofficially known as the “Mission of Peace”.
***
1️⃣0️⃣6️⃣minutes of Yuri Gagarin's flight changed the course of world history.
Just 16 years after the most devastating and bloodiest war in human history, the Soviet people achieved what had only recently seemed impossible – opening the way to space for all humankind.
***
💬 As President Vladimir Putin noted in his message to the participants in the first Russian Space Forum on April 9, 2026:
Yuri Gagarin's spaceflight became one of the great events of the 20th century and opened a new era in the history of human civilisation.
We are sincerely proud of several generations of talented scientists, designers, cosmonauts, military personnel and civilian specialists who stood at the origins of the national space programme and wrote bright, heroic pages in the chronicle of its victories and achievements.
🇺🇳 Since 2011, April 12 has been observed as the International Day of Human Space Flight, proclaimed by the UN General Assembly under resolution A/RES/65/271 in honour of Yuri Gagarin’s legendary mission.
#Gagarin65#FirstInSpace