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

Резултати

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

Пребарај: #ilva

当前筛选 #ilva清除筛选
Ultimora.net - POLITICS

@ULTIMORAPOLITICS · Post #42198 · 17.11.2022 г., 12:56

È terminato al ministero delle Imprese e del Made in Italy il tavolo sull'ex #Ilva convocato dal ministro Adolfo #Urso in merito alla sospensione delle attività fino al 16 gennaio 2023. @UltimoraPolitics

Hashtags

Maurizio Vezzosi

@mauriziovezzosi · Post #118 · 30.11.2019 г., 15:20

Il mio - altro - videoracconto della giornata della manifestazione che si è svolta ieri a Taranto. Per Ruptly. Taranto (Italy) 29th november 2019 - Hundreds of Ilva workers, Europe's largest steel plant owned by the French-Indian multinational Arcelor-Mittal, held a general strike in Taranto on Friday, to protest against the company's plans to layoff thousands of workers as well as the toxic waste the plant has spewed over the city. "As has always been the case, we demand two basic rights that are written in our Constitution; the right to work and the right to the health," Vincenzo Mercurio a worker and a trade union delegate said. Reports say the protest was joined by a large number of students and activists associated with 'Fridays for Future' and 'Youth for Climate' groups. "The reason why we, students and citizens, are protesting is that we are tired of speaking with people that refuse to respect our rights and to listen to us; people that are busy worrying about their interests, not the people's ones. And we are tired of people showing that they are representing us, although they are just trying to gain our votes," Sara Pierpoli a student and protester said. The Italian government and the world's largest steelmaker Arcelor-Mittal are in dispute over pollution levels and the company's legal position while Rome is considering options to keep the plant open and save thousands of jobs. Video and text by Maurizio Vezzosi #steel#ilva#italsider#italy#climatestrike#fridayforfuture#strikeforclimate https://youtu.be/7xS2zjstqKs

Maurizio Vezzosi

@mauriziovezzosi · Post #116 · 29.11.2019 г., 17:10

#Taranto. I lavoratori del polo siderurgico ex-Ilva (ex-Italsider) scioperano con un'adesione sopra al 70% e scendono in piazza insieme ai giovani per l'ambiente, la salute, il lavoro: una battaglia per l'#Italia contro i saccheggi delle multinazionali. Il mio video-racconto per Il Fatto Quotidiano. #acciaio#ilva#italsider#iri#climatestrike#fridayforfuture#strikeforclimate