Метод строки isidentifier() поможет узнать, подходит ли данная строка в качестве имени объекта.
Вполне может заменить самостоятельно придуманную регулярку.
>>> 'some_name'.isidentifier()
True
Обычное имя переменной
>>> '私は手紙です'.isidentifier()
True
Юникод в качестве имени тоже доступен
>>> '1_name'.isidentifier()
False
Имя не может начинаться с цифры
>>> '੬_name'.isidentifier()
False
Включая все цифры юникода
>>> 'some name'.isidentifier()
False
Пробелы недопустимы
#basic
Joan of Arc was captured in 1430 during the Hundred Years’ War by the Burgundians, who then handed her over to the English. The preliminary hearings and interrogations in her trial began on January 3, 1431, with the official trial sessions starting on January 9, 1431. She faced charges including heresy and cross-dressing in a politically motivated trial aimed at discrediting her and weakening French morale. Despite her bravery and clear faith, she was found guilty and burned at the stake in 1431 at just 19 years old. Later, she was declared a saint and became a symbol of French unity and courage. ⚔️🔥🙏
[Read more]
#JoanOfArc#History#Heroine#MedievalTimes#SaintJoan