Метод строки isidentifier() поможет узнать, подходит ли данная строка в качестве имени объекта.
Вполне может заменить самостоятельно придуманную регулярку.
>>> 'some_name'.isidentifier()
True
Обычное имя переменной
>>> '私は手紙です'.isidentifier()
True
Юникод в качестве имени тоже доступен
>>> '1_name'.isidentifier()
False
Имя не может начинаться с цифры
>>> '੬_name'.isidentifier()
False
Включая все цифры юникода
>>> 'some name'.isidentifier()
False
Пробелы недопустимы
#basic
🌎 On Neptune’s largest moon Triton, geysers of nitrogen ice erupt from beneath the surface, shooting plumes up to 8 kilometers high into the tenuous atmosphere. These cryovolcanic eruptions are driven by sunlight warming a thin layer of transparent ice, a unique phenomenon that shapes Triton's mysterious, dark-streaked terrain. ✨
#Triton⚡#cryovolcanism⚡#Neptune
👉subscribe Universe Mysteries
🪐 Pluto's largest moon, Charon, may hold a secret beneath its icy exterior—a hidden ocean of liquid water. Signs of ancient cryovolcanism (volcanoes that erupt ice instead of lava) and fractures in Charon’s surface, revealed by NASA’s New Horizons spacecraft, suggest that internal heat could have once melted the ice deep inside, creating an underground sea in this distant, frozen world. ✨
#Charon⚡#oceans⚡#cryovolcanism⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels