Метод строки isidentifier() поможет узнать, подходит ли данная строка в качестве имени объекта.
Вполне может заменить самостоятельно придуманную регулярку.
>>> 'some_name'.isidentifier()
True
Обычное имя переменной
>>> '私は手紙です'.isidentifier()
True
Юникод в качестве имени тоже доступен
>>> '1_name'.isidentifier()
False
Имя не может начинаться с цифры
>>> '੬_name'.isidentifier()
False
Включая все цифры юникода
>>> 'some name'.isidentifier()
False
Пробелы недопустимы
#basic
Whenever NEA receives feedback on noise or smell nuisance, #NEAofficers such as Joey would investigate the root cause and try to resolve the issues for residents. Read on to find out more about his winning formula: https://www.facebook.com/NEASingapore/posts/324902236450865
#PeopleofNEA#NEA20
When #NEAOfficer Hamdan received a compliment from a resident for responding to his feedback on a Sunday, he was very surprised. Read on to find out why: https://www.facebook.com/NEASingapore/posts/344176487856773
#PeopleofNEA#NEA20
What is the skill that our #NEAofficer, Sarmad, learnt at 16 years old that became useful when he turned 60? Read on to find out more: https://www.facebook.com/NEASingapore/posts/334885492119206
#PeopleofNEA#NEA20