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

Резултати

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

Пребарај: #climateactionsg

当前筛选 #climateactionsg清除筛选
NEA Singapore

@NEASingapore · Post #50 · 04.05.2020 г., 05:04

It’s May the 4th! Saving the earth is in your hands, so may the force be with you. Like ice cream in this hot Singapore weather, the earth’s great ice caps are melting due to global warming! It’s time to ask ourselves if we have done enough for the earth. If not, start here: www.mewr.gov.sg/climateaction#ClimateActionSG

NEA Singapore

@NEASingapore · Post #1043 · 20.05.2025 г., 01:03

💰 Save around $80 annually when you upgrade your refrigerator from 1-tick to 3-tick or above! 🌱 Take climate action by switching to more energy- and water-efficient appliances with your Climate Vouchers! The Climate Friendly Households Programme now offers: 🎉 Additional $100 in Climate Vouchers, on top of the $300 in 2024 for eligible HDB households (total $400!) 🏠 Now extended to all Singapore Citizen households in private properties too ⏰ Valid until 31 Dec 2027 👉 For more details: go.gov.sg/cfhp-info #EnergyEfficiency#ClimateActionSG#SustainableSG

NEA Singapore

@NEASingapore · Post #1041 · 13.05.2025 г., 03:39

💡✨ Bright savings are just a switch away. Switch 5 compact fluorescent lamps for 2-tick LED bulbs and save $32 a year! Take climate action by switching to more energy- and water-efficient appliances with your Climate Vouchers. ✅ The Climate Friendly Households Programme now offers an additional $100 in Climate Vouchers, on top of the $300 offered in 2024 for eligible HDB households. ✅ The programme has also been expanded to include Singapore Citizen households living in private residential properties in 2025. ✅ This means that all eligible HDB and private households have been issued $400 worth of Climate Vouchers. These vouchers are valid until 31 Dec 2027. More details at go.gov.sg/cfhp-info #EnergyEfficiency#ClimateActionSG#SustainableSG

NEA Singapore

@NEASingapore · Post #1037 · 06.05.2025 г., 02:46

💰𝗖𝗼𝗼𝗹 𝘀𝗮𝘃𝗶𝗻𝗴𝘀 𝗮𝗹𝗲𝗿𝘁! Upgrade to a 5-tick air-conditioner and enjoy about $450 savings in utilities a year compared to a 1-tick model. Take climate action by switching to more energy- and water-efficient appliances with your Climate Vouchers. The Climate Friendly Households Programme now offers an additional $100 in Climate Vouchers, on top of the $300 offered in 2024 for eligible HDB households. The programme has also been expanded to include Singapore Citizen households living in private residential properties in 2025. This means that all eligible HDB and private households have been issued $400 worth of Climate Vouchers. These vouchers are valid until 31 Dec 2027. More details at go.gov.sg/cfhp-info #EnergyEfficiency#ClimateActionSG#SustainableSG

NEA Singapore

@NEASingapore · Post #1026 · 15.04.2025 г., 02:02

The Climate Friendly Households Programme now offers an additional $100 in Climate Vouchers, on top of the $300 offered in 2024. It has been expanded to include Singapore Citizen households in private residential properties on top of eligible HDB households. Take climate action by switching to more energy- and water-efficient appliances with your Climate Vouchers. The vouchers are valid until 31 Dec 2027. Visit go.gov.sg/climatevouchers for more info. #ClimateActionSG#SustainableSG#EnergyEfficiency

NEA Singapore

@NEASingapore · Post #28 · 28.03.2020 г., 04:00

It's #EarthHour tonight! Don’t forget to turn off all your lights at 8.30pm today. And because we only have one earth, let’s ensure we use our resources wisely. Read more here: earthhour.org #ClimateActionSG

NEA Singapore

@NEASingapore · Post #998 · 18.02.2025 г., 09:18

#SGBudget2025 The enhanced Climate Friendly Households Programme will now cover around 90% of households in Singapore! From 15 Apr 2025, eligible HDB households will receive an additional $100 in Climate Vouchers, on top of the existing $300 offered in 2024. The programme will also be expanded to include Singapore Citizen households living in private residential properties. This means that eligible households staying in HDB and private residential properties can claim a total of $400 worth of Climate Vouchers! These vouchers are valid until 31 Dec 2027. More info at go.gov.sg/nea-cos2025-cv #ClimateActionSG#SustainableSG

NEA Singapore

@NEASingapore · Post #908 · 26.09.2024 г., 01:00

This year's theme, 'Creating Resilient Communities through Disaster Risk Reduction and Climate Change Mitigation and Adaptation’, highlights the urgent need to build stronger, more adaptable communities in the face of global challenges. By taking climate actions such as practising the 3Rs and adopting energy-saving habits, all of us can play a part in building a more resilient and #SustainableSG🌱💪 #WorldEnvironmentalHealthDay#SustainableSG#ClimateActionSG