Метод строки isidentifier() поможет узнать, подходит ли данная строка в качестве имени объекта.
Вполне может заменить самостоятельно придуманную регулярку.
>>> 'some_name'.isidentifier()
True
Обычное имя переменной
>>> '私は手紙です'.isidentifier()
True
Юникод в качестве имени тоже доступен
>>> '1_name'.isidentifier()
False
Имя не может начинаться с цифры
>>> '੬_name'.isidentifier()
False
Включая все цифры юникода
>>> 'some name'.isidentifier()
False
Пробелы недопустимы
#basic
After fighting for more than two months in the war and enduring another two and a half months of ceasefire, Hezbollah fighter Mohamad, who had been pronounced dead, has been found alive under the rubble in the occupied southern Lebanese village of Kfarkila along with another fighter eho was also found alive.
#Lebanon#Hezbollah#Kfarkila
Israel has begun constructing a concrete wall along the Blue Line, which separates Israel from Lebanon, encroaching on Lebanese territory.
The wall is being built inside the town of Kfar Kila, with a significant portion of the village’s land now falling within the occupied territories.
As part of the construction, the old wall was demolished, bringing the new structure even closer to the village.
This development has resulted in buildings and shops within Kfar Kila now being trapped on the wrong side of the Blue Line.
#IsraelWall#Lebanon#KfarKila#LandGrab#LebanonVsIsrael#LebaneseBorder#IsraeliAggression#BlueLine#Occupation#Israel