Метод строки isidentifier() поможет узнать, подходит ли данная строка в качестве имени объекта.
Вполне может заменить самостоятельно придуманную регулярку.
>>> 'some_name'.isidentifier()
True
Обычное имя переменной
>>> '私は手紙です'.isidentifier()
True
Юникод в качестве имени тоже доступен
>>> '1_name'.isidentifier()
False
Имя не может начинаться с цифры
>>> '੬_name'.isidentifier()
False
Включая все цифры юникода
>>> 'some name'.isidentifier()
False
Пробелы недопустимы
#basic
Live: Get your virtual panda cuddles from Chongqing Zoo!
It's Saturday! Time for some super cute pandas. Yu Ai, Yu Ke, Mang Cancan, Qi Sanmei and Liang Yue in Chongqing Zoo get ready for clumsy rolls, silly play and fluffy cuteness. Join us to have a look! #panda
via CGTN
🩸🅰️🩸🩸🅰️
A Chinese zoo is under fire again for passing off dogs as pandas. This is the third time that people have been tricked by painting ordinary chow chows as pandas.
Visitors began to suspect that they weren't pandas when the spotted furry creatures started barking and panting like dogs.
The plan was perfect. What could go wrong?
#Panda#China
MARKHEMIST