Метод строки isidentifier() поможет узнать, подходит ли данная строка в качестве имени объекта.
Вполне может заменить самостоятельно придуманную регулярку.
>>> 'some_name'.isidentifier()
True
Обычное имя переменной
>>> '私は手紙です'.isidentifier()
True
Юникод в качестве имени тоже доступен
>>> '1_name'.isidentifier()
False
Имя не может начинаться с цифры
>>> '੬_name'.isidentifier()
False
Включая все цифры юникода
>>> 'some name'.isidentifier()
False
Пробелы недопустимы
#basic
🌍 Zealandia is mostly underwater and is considered Earth's hidden continent. Only a tiny part, including New Zealand, rises above the Pacific Ocean’s surface, making it nearly invisible on world maps. ✨
#continent⚡#ocean⚡#Zealandia⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
Donald #Trump veut fournir beaucoup de #gaz à l’Europe, mais ce n’est pas si facile
En bon commerçant, le nouveau président #américain voudrait inonder l’Europe de son gaz liquéfié dont le prix reste élevé. Dans le même temps le Vieux #Continent n’a pas réussi à couper sa dépendance au #GNL russe bon marché, sans lequel l’économie de la zone euro risquerait de se dégrader encore plus. Notre reporter Igor Kourachenko nous rejoint avec toutes les précisions.
RT en français • Osez questionner !