Бывает начинающие в процессе обучения создают файлы с именем модуля который они изучают. В результате на тестовых запусках ничего не работает😱
Всё потому, что появилась коллизия имён. Например, изучаете вы модуль datetime, и создаёте с таким именем файл (ну логично же😄) прямо в рабочей директории.
Потом, при попытке импортировать datetime модуль, из-за приоритета импорта будет импортирован файл из рабочий директории а не оригинальная библиотека. Ведь имя файла это суть имя модуля!
А знаете ли вы, что не все стандартные модули можно так перезаписать? Коллизии имён не подвержены builtin модули. Они всегда стоят на первом месте в приоритете импорта, поэтому их нельзя заменить.
Полный список таких модулей можно посмотреть в списке sys.builtin_module_names.
То есть, вы сломаете весь Python если назовёте свой модуль os или site, но если назовёте time или gc то ничего страшного не случится)))
Тем не менее, никогда не называйте модули уже занятыми именами!!!⚠️
Я всегда рекомендую всем своим файлам делать именной префикс из 2-3 символов. Например я называю свои проекты так:
pw_project_name
pw_ui_tools.py
pw_something/main.py
Либо под ситуацию
tst_scriptname.py
(не "test" чтобы не подхватывал pytest)
dbg_script.py
maya_ui.py
hou_menu_tools.py
И искать проще, и коллизий нет.
#tricks#basic
Let’s unlock all your Rat-Dex discoveries! Spot the signs early so we can stop them before they multiply. Help your neighbourhood stay rat-free by reporting signs of rat activity through the OneService app. #KeepSGClean
Don’t dump furniture at void decks or common areas.
🏢 HDB → Contact your Town Council
🏠 Private estate → Contact a public waste collector
Bulky items deserve proper disposal—keep our shared spaces safe & clean 🌍💚
#KeepSGClean
Cups and containers left behind in our shared spaces can trap water and turn into mozzie breeding spots. Pack up your litter, throw them into the bin and #KeepSGClean!
High-rise litter isn’t just messy; it’s dangerous. Let’s keep our shared spaces safe and clean. If you spot litterbugs, report them via the OneService app with details like date, time and location.
#KeepSGClean
Barbecue parties are fun, but piles of litter after aren’t. Food scraps & waste attract pests and make shared spaces unpleasant.
Let’s do our part and bin our waste. Spot someone leaving a mess? Report via the OneService app with date, time & exact location. Let’s keep our chill spots truly chill! #KeepSGClean
The food slapped 😋, but your leftovers? Not so much. Improper disposal of food waste = pests, smells, and fines up to $2,000. Let’s clear our mess before we leave and report littering via the OneService app with details such as date, time and precise location. #KeepSGClean
Your game might be 🔥 but leaving trash behind in public sports facilities is a major foul. Offenders can be fined up to $2,000 for first-time littering.
If you spot litterbugs, report them via the OneService app with details such as date, time and precise location. Let's keep our public sports facilities clean for everyone's game! #KeepSGClean
Pests, like rats, love their new homes within bulky waste. Do you? 🐀
To rid them of their new homes, keep public spaces clear of food and clutter!
HDB: Contact your Town Council
Private homes: Engage licensed collector 👉go.gov.sg/licensed-waste-collectors
Spot bulky waste left in common areas? Report via the OneService app with details such as date, time and precise location (block stack or column). Together, let’s #KeepSGClean!
Clean spaces protect our peace of mind ✨ Dispose of waste responsibly and help keep our shared areas uplifting for all.
Witness littering? Report it via the OneService app with details such as date, time and precise location. Together, let’s #KeepSGClean!