Метод строки isidentifier() поможет узнать, подходит ли данная строка в качестве имени объекта.
Вполне может заменить самостоятельно придуманную регулярку.
>>> 'some_name'.isidentifier()
True
Обычное имя переменной
>>> '私は手紙です'.isidentifier()
True
Юникод в качестве имени тоже доступен
>>> '1_name'.isidentifier()
False
Имя не может начинаться с цифры
>>> '੬_name'.isidentifier()
False
Включая все цифры юникода
>>> 'some name'.isidentifier()
False
Пробелы недопустимы
#basic
Curated Crypto | ꘜ
🤑WTF: ETH options open interest just hit a 1.5-year high!
Degens are loading up on longs, while whales are stacking ETH at all-time record pace!
But hedge funds are going mega short - CME ETH futures short positioning just keeps smashing new records!
Green But Red in real life!
#WTF
The suspect attempted to escape an interrogation room by breaking through the wall while no one was watching—only to be caught shortly after.
@Viral_Today / #wtf
Imagine a coffee table that moves around the house by itself—well, you don’t have to anymore because it’s real. It’s just as fascinating as it is creepy.
@Viral_Today / #wtf