У строки в Python есть два очень похожих метода. На столько похожих что кажется они делают одно и тоже.
Это метод isdigit() и isnumeric()
Давайте посмотрим зачем нам два одинаковых метода? И так ли они одинаковы?
Очевидно что isdigit() говорит нам, состоит ли строка только из чисел 0-9
>>> '12'.isdigit()
True
>>> '12x'.isdigit()
False
>>> '-12'.isdigit()
False
>>> '12.5'.isdigit()
False
Можно предположить что isnumeric() делает более глубокий анализ и распознаёт в строке float или отрицательное число.
>>> '15'.isnumeric()
True
>>> '-15'.isnumeric()
False
>>> '15.2'.isnumeric()
False
Нет, всё так же как и с другим методом. В чем же тогда разница? Для начала посмотрим следующие примеры:
>>> '5'.isdigit(), '5'.isnumeric() # Обычная цифра 5
# True, True
>>> '꧕'.isdigit(), '꧕'.isnumeric() # Яванская 5
# True, True
>>> '෩'.isdigit(), '෩'.isnumeric() # Синхала 3
# True, True
>>> '৩'.isdigit(), '৩'.isnumeric() # Бенгальская 3
# True, True
>>> '༣'.isdigit(), '༣'.isnumeric() # Тибетская 3
# True, True
>>> '³'.isdigit(), '³'.isnumeric() # 3 верхний индекс (степень)
# True, True
>>> '𝟝'.isdigit(), '𝟝'.isnumeric() # Математическая двойная 5
# True, True
>>> '๔'.isdigit(), '๔'.isnumeric() # Тайская 4
# True, True
>>> '➑'.isdigit(), '➑'.isnumeric() # 8 в круге
# True, True
А теперь примеры в которых, по мнению Python, результаты не равны
>>> '¾'.isdigit(), '¾'.isnumeric() # дробь три четверти
# False, True
>>> '⅕'.isdigit(), '⅕'.isnumeric() # дробь одна пятая
# False, True
>>> '𒐶'.isdigit(), '𒐶'.isnumeric() # клинопись 3
# False, True
>>> '三'.isdigit(), '三'.isnumeric() # 3 из унифицированной идеограммы
# False, True
>>> '⑩'.isdigit(), '⑩'.isnumeric() # цифра 10 в круге
# False, True
>>> 'Ⅳ'.isdigit(), 'Ⅳ'.isnumeric() # Римская 4
# False, True
>>> '𑇪'.isdigit(), '𑇪'.isnumeric() # Сенегальская архаическая 10
# False, True
>>> '𐌢'.isdigit(), '𐌢'.isnumeric() # Этрусская цифра 10
# False, True
>>> 'ↂ'.isdigit(), 'ↂ'.isnumeric() # Римская цифра 10000
# False, True
>>> '〇'.isdigit(), '〇'.isnumeric() # Символ ККЯ ноль
# False, True
Получается, что isdigit() говорит нам, является ли символ десятичной цифрой или спецсимволом, имеющим цифирное значение после преобразования.
В свою очередь isnumeric() включает все дополнительные символы юникода которые имеют отношения к числовым и цифровым представлениям.
Ну и пара примеров в которых в обоих случаях символ не является числом, это эмодзи.
>>> '🕙'.isdigit(), '🕙'.isnumeric() # эмодзи 10 часов
# False, False
>>> '7️⃣'.isdigit(), '7️⃣'.isnumeric() # эмодзи 7
# False, False
Также есть еще один дополнительный и весьма полезный метод isdecimal().
Он нам сообщает, можно ли из указанного символа сделать простую десятичную цифру. То есть сработает ли метод int(x)
>>> '෩'.isdecimal(), int('෩') # Синхала 3
# True, 3
>>> '➑'.isdecimal(), int('➑') # 8 в круге
# False, ValueError
Какие выводы?
🔸 При определении цифры в строке isdigit() подходит лучше чем isnumeric(), но оба не гарантируют успешную конвертацию в int
🔸 Для однозначного определения возможности преобразования строки в int лучше подходит метод isdecimal()
🔸 Для однозначного определения символов 0...9 лучше использовать regex
Полный список символов юникода которые определяются как numeric
#basic
Latvia Publishes “Vatniks Map”: Surprising Scale of Pro-Russian Support
Latvia’s State Security Service released a map showing individuals supporting Russia and the Russian language. Businessman Alexey Roslikov called it a defeat for the Latvian regime, revealing many reasonable people tired of government policies. Support exists not only in Russian-speaking areas but also among Latvians. However, the surveillance itself reflects Latvia’s tense political climate.
#Latvia#Russia#Politics#Security
The main news of Russia and the world ishere.
🇱🇻#Latvia - 🇪🇪#Estonia - 🇧🇪#Belgium: Latvia, Estonia, and Belgium have become the first NATO countries to begin deploying the "Blaze" fully autonomous interceptor drone system along their borders amid increasing reports of unauthorized drone incursions in their airspace.
Developed and manufactured in Latvia by Origin Robotics, the Blaze is an autonomous counter-drone interceptor designed to detect, track, and destroy hostile drones and other fast moving aerial targets using radar, AI powered computer vision, and a high explosive fragmentation warhead.
(via Origin Robotics)
📝Friendly fire on the Balts📝
on the Ukrainian attack on Latvia
A new wave of Ukrainian drones targeting Russia today again affected Russia's northwestern regions with the final destination being ports in the Gulf of Finland. And once again, Ukrainian formations used the already standard corridor through the Baltic states.
🖍Only this time the flight path through Latvia went wrong: several Ukrainian UAVs went off course and began striking Latvian territory. At least one impact was recorded on an oil depot in Rezekne. The Latvians were lucky that it was empty, so the damage turned out to be minimal.
In addition, flights of several more drones (visually these were either An-196 "Lyuty" or FP-1) were noted in other areas of Latvia. There was also information about a passenger train being hit, but preliminarily this was fake – video of a burning train, as they say, from May 6.
🚩The UAV flight route sparked a new wave of discussion: given that the Russian Ministry of Defense reported shooting down UAVs over Novgorod Region, some UAVs definitely flew from Chernihiv Region along a route parallel to Belarus with a subsequent entry into the Baltic states to reach the Gulf of Finland.
🏳️This route is most practical for Ukrainian attacks using Starlink terminals. Musk's systems don't work over Russia, but the international waters of the Gulf of Finland or NATO countries – . Especially since FP-1s have recently been frequently used with "Musk's carriers."
❗️The main question: why did the UAVs choose the Latvian oil depot as a target? A possible piloting malfunction, as well as an error in the target identification system through machine vision, could have led to a false identification of the object in Rezekne.
Will Latvia say anything about this? They'll puff out their cheeks menacingly and ask their Ukrainian partners not to do this again. But of course, no one will listen to them, given the practical value of such a route for strikes on ports in Leningrad Region.
📍
#Belarus#Latvia#Russia#Estonia
✈ | ✈ | ✉
✉️ | ✉️ | ✉️ | ✉️
💸
🎬@zeitframe
📝 Рига о начале реконструкции одного из старейших районов Чиекуркалнс. Čiekurkalns, дословно «Гора шишек» Застройка района началась около 1870 года на землях усадьбы Шрейенбуш. Первоначально главная улица называлась Шрейенбушская 1-я линия. Застройка велась без плана, официальных названий улицам не давали, и до настоящего времени старейшие улицы Чиекуркалнса называются «линиями». #рига#Латвия#riga#latvia#прошлое
@ciekurkalns
📊Коммерческий суд Лондона (EWHC) и страны постсоветского пространства: январь–август 2025
Мы проанализировали практику Commercial Court, King’s Bench Division, EWHC и получили следующие результаты:
🇷🇺 Россия — 17 дел
🇺🇦 Украина — 3 дела
🇰🇿 Казахстан — 1 дело
🇱🇻 Латвия — 2 дела
🇬🇪 Грузия — 1 дело
⚖️Почему это важно?
Лондон остаётся мировым центром разрешения коммерческих споров: именно сюда бизнес из России, Украины, Казахстана и других стран обращается за защитой.
Commercial Court специализируется на международных договорах, инвестиционных и банковских спорах, морском праве и арбитражных вопросах.
Для компаний региона это — сигнал о необходимости готовиться к возможным процессам в Лондоне и учитывать английское право в своей стратегии.
📌 Мы будем отслеживать каждое дело в EWHC Commercial Court, анализировать судебную логику и тактику сторон.
👉 В следующем посте мы подробно разберём, по каким основаниям компании и частные лица из стран бывшего СССР обращались в Коммерческий суд Лондона.
🔎 Хотите понимать, как решения английских судов влияют на бизнес в регионе? Подписывайтесь, чтобы не пропустить следующий разбор!
#EWHC#CommercialCourt#LondonCourt#EnglishLaw#DisputeResolution#InternationalLitigation#LegalStrategy#Russia#Ukraine#Kazakhstan#Latvia#Georgia#PostSoviet#CrossBorderDisputes#ЛондонскийСуд#АнглийскоеПраво#МеждународныеСпоры
NATO PLAN TO CREATE "DRONE WALL" FOR "DEFENCE AGAINST RUSSIA" FROM NORWAY TO POLAND
Baltic members of #NATO have called for a "drone wall" along their borders with #Russia, despite Moscow's warnings against the hostile activities of the military bloc along its #borders.
It comes as #Poland also mulls the possibility of downing #Russian missiles over #Ukraine with its own air defence systems.
Interior ministers of the #Latvia, #Lithuania, #Estonia, #Poland, #Finland met last week in Riga, Latvia to discuss ways of coordinating their defense capabilities.
#Lithuanian Interior Minister Agne #Bilotaite said in a press release on Friday:
"We see constant efforts” from Russia and #Belarus to “destabilize our countries’ internal security and public order, to create panic and distrust in institutions,”
#Bilotaite accused Minsk and Moscow of
“weaponizing #migration, #CyberAttacks, #disinformation, #sabotage of critical infrastructure and other #hybrid threats.”
📌FLEX APPLICATION IS NOW OPEN!🇺🇿🇺🇸
📌Did you know that the FLEX Program accepts applications from secondary school students in *22 countries* in Europe and Eurasia? Since 1993, more than 29,000 students have experienced life in the United States with the #FLEXProgram, living with a U.S. host family, and attending a U.S. high school.
Applications for FLEX 2023-24 are due on October 13! Learn more about applying at: discoverflex.org/apply
📌The Future Leaders Exchange (FLEX) Program FLEX is a highly competitive, merit-based scholarship program funded by the U.S. Department of State that operates in #Armenia, #Azerbaijan, the #CzechRepublic, #Estonia, #Georgia, #Greece, #Hungary, #Kazakhstan, #Kyrgyzstan, #Latvia, #Lithuania, #Moldova, #Mongolia, #Montenegro, #Poland, #Romania, #Serbia, #Slovakia, #Tajikistan, #Turkmenistan, #Ukraine, and #Uzbekistan.
📌FLEX APPLICATION IS NOW OPEN!🇺🇿🇺🇸
📌Did you know that the FLEX Program accepts applications from secondary school students in *22 countries* in Europe and Eurasia? Since 1993, more than 29,000 students have experienced life in the United States with the #FLEXProgram, living with a U.S. host family, and attending a U.S. high school.
Applications for FLEX 2023-24 are due on October 13! Learn more about applying at: discoverflex.org/apply
📌The Future Leaders Exchange (FLEX) Program FLEX is a highly competitive, merit-based scholarship program funded by the U.S. Department of State that operates in #Armenia, #Azerbaijan, the #CzechRepublic, #Estonia, #Georgia, #Greece, #Hungary, #Kazakhstan, #Kyrgyzstan, #Latvia, #Lithuania, #Moldova, #Mongolia, #Montenegro, #Poland, #Romania, #Serbia, #Slovakia, #Tajikistan, #Turkmenistan, #Ukraine, and #Uzbekistan.