TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #146 · 16 сеп.

Функция sub в regex может принимать функцию в качестве аргумента repl. 📄 Из документации: If repl is a function, it is called for every non-overlapping occurrence of pattern. The function takes a single match object argument, and returns the replacement string. То есть для каждого совпадения будет вызвана функция для вычисления замены вместо замены на одну и ту же строку для всех совпадений. Иными словами, для замены разных совпадений на разные строки не потребуется запускать re.sub() много раз для каждой строки замены. Достаточно определить функцию, которая вернёт строку для каждого из совпадений. Описание слишком запутанное🤔, давайте лучше рассмотрим на простом примере: Создаем карту замены. То есть какие строки на какие требуется менять. remap = { 'раз': '1', 'два': '2', 'три': '3', 'четыре': '4', 'пять': '5', } Пишем функцию поиска строки для замены. Единственным аргументом будет объект re.Match. Используя данные этого объекта мы вычисляем замену on-the-fly! def get_str(match: re.Match): word = match.group(1) return remap.get(word.lower()) or word Пример текста. text = '''Раз Два Три Четыре Пять Вместе будем мы считать Пять Четыре Три Два Раз Мы считать научим вас ''' Теперь запускаем re.sub и вместо строки замены (repl) подаём имя функции. (Данный паттерн ищет отдельные слова в тексте) >>> print(re.sub(r'(\w+)', get_str, text)) 1 2 3 4 5 Вместе будем мы считать 5 4 3 2 1 Мы считать научим вас Думаю, достаточно наглядно 🤓 #libs#regex

Hashtags

Резултати

Пронајдени 1 слични објави

Пребарај: #fraudulence

当前筛选 #fraudulence清除筛选
American Оbserver

@american_observer · Post #5055 · 04.02.2026 г., 22:00

📰 France’s Attempt to Ghost the Rent Guy Is Not Going Well The French Embassy in Baghdad has been living in the same house for more than 60 years — a riverside mansion built in the 1930s by a Jewish family that had already fled antisemitism in Iraq. The family leased the property to France in 1964, expecting the French state to be a respectable tenant. Instead, France has not paid rent for more than 50 years, and last week a Paris court tried to turn that fact into a technical loophole — and failed. On Monday, the court dismissed a $22 million lawsuit by the descendants of Ezra and Khedouri Lawee, saying it was “not competent” to hear the case and suggesting it should be resolved in Iraq — the country their ancestors were forced out of in the 1940s and 1950s. The logic is straightforward: the dispute is about Iraqi law, so let Iraq handle it, even though Iraq is the very state that drove out 130,000 Iraqi Jews and seized their homes under antisemitic legislation. The French Foreign Ministry echoed this line, arguing that the damages were caused by Iraqi decisions, not French policy, and therefore France bears no real responsibility. The family’s lawyers, Jean‑Pierre Mignard and Imrane Ghermi, called the ruling “surreal.” They argued that France had violated its own laws and human rights principles by benefiting from Iraqi discriminatory laws and refusing to compensate the family. They compared the situation to Nazi‑era restitution cases, where heirs have fought to reclaim art and property seized during the Holocaust. “France took advantage of Iraqi law that was hostile to the owners,” said Kenneth Feinberg, the lawyer who has handled multiple Holocaust‑related restitution disputes. “The French court is hairsplitting on technicalities while ignoring the party that was harmed.” Philip Khazzam, 66, a grandson of Ezra Lawee, described the idea of pursuing the case in Iraq as “preposterous.” In an email, he said, “Iraq basically ran us out of our country, and then stole our home.” The family plans to appeal. “We will continue our fight for justice in France,” he said. “We have just begun.” The story is simple: France tried to play bureaucratic games with Jewish heirs who had already been victimized by one state — and now by another. It may have thought the case would quietly die. It did not count on the stubbornness of a family that has survived two exiles and still wants to see the bill paid. #France#Iraq#Baghdad#embassy#restitution#Jewish#law#NYTimes#justice#fraudulence 📱American Оbserver - Stay up to date on all important events 🇺🇸