Метод строки isidentifier() поможет узнать, подходит ли данная строка в качестве имени объекта.
Вполне может заменить самостоятельно придуманную регулярку.
>>> 'some_name'.isidentifier()
True
Обычное имя переменной
>>> '私は手紙です'.isidentifier()
True
Юникод в качестве имени тоже доступен
>>> '1_name'.isidentifier()
False
Имя не может начинаться с цифры
>>> '੬_name'.isidentifier()
False
Включая все цифры юникода
>>> 'some name'.isidentifier()
False
Пробелы недопустимы
#basic
Beavers build dams to protect themselves from predators like bears and wolves. They live in lodges, not in the dam itself, on deep ponds made by the dams. These lodges have underwater entrances, so beavers can safely enter and leave without being seen. The pond keeps land animals away and the lodge is a dry home and food storage. 🦫🌊🌿@googlefactss#Beavers#Wildlife#Nature#AnimalFacts
In 1995, wolves were reintroduced to Yellowstone, sparking a remarkable ecological revival. Their presence changed elk behavior, allowing vegetation along riverbanks to recover. This regrowth stabilized soil and encouraged beaver populations to thrive, whose dams further improved water retention and created diverse aquatic habitats. Together, wolves and beavers helped reshape the ecosystem, even altering river flows. 🐺🦫🌿🌊
[Read more]
@googlefactss
#Wolves#Beavers#Yellowstone#EcosystemRestoration#RiverRevival#Conservation#NaturePower