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

Резултати

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

Пребарај: #epiphany

当前筛选 #epiphany清除筛选
Addis Standard

@addisstandardeng · Post #21111 · 19.01.2026 г., 10:21

In_Pictures: #Epiphany celebrations across #Ethiopia Epiphany (Timket) celebrations are taking place across Ethiopia, as followers of the Ethiopian Orthodox Tewahedo Church mark the festival in accordance with long-standing religious traditions. Observances began on the eve of the Katara ceremony yesterday, with clergy and congregants participating in the commemoration. Photo: Social media

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40485 · 06.01.2026 г., 03:04

January 6 is Epiphany or Theophany. Wise Men, or magi, visited baby Jesus with gifts: gold, frankincense, and myrrh. The Bible doesn’t say how many magi came or their names; tradition says three: Melchior, Caspar, and Balthazar. Some churches also celebrate Jesus’ baptism this day. Before December 25 was Christmas, January 6 was the main day to celebrate Jesus’ birth. It ends the 12 days of Christmas with food, parades, and gifts. ✝️🎁⭐ [Read more] We wish you all a happy Epiphany day. @googlefactss#Epiphany#Jesus#Christmas#ChristianTraditions#History

☦️Epiphany and the Cross-Diving Tradition On the feast of the Epiphany, believers in a number of countries take part in a folk-religious tradition known as cross diving. 🔹 After the blessing of the water, a priest throws a cross into a body of water — a river, lake, or the sea. 🔹 Participants then swim to retrieve the cross from the water. 🔹 It is believed that the person who retrieves the cross first receives a special blessing for the year ahead. 🌍 This tradition is especially common in countries with a warmer climate than Russia, such as Greece, Bulgaria, Serbia, as well as in several other countries and regions. 🇷🇺🇿🇦 This tradition is also practiced within the Russian-speaking diaspora in South Africa. 📸Photo (Cape Town) 🔗Source: https://t.me/Capetown_SouthAfrica_chat/50655 #Epiphany#Orthodoxy#ChristianTraditions#Culture#Religion#FolkTraditions#SouthAfrica#CapeTown

Addis Standard

@addisstandardeng · Post #21118 · 19.01.2026 г., 13:37

In Pictures 2 #Ethiopians across the country celebrate Timket (#Epiphany)—recognized by #UNESCO as an intangible cultural heritage of humanity—one of the Ethiopian Orthodox Church’s most sacred festivals, marked by vibrant processions, prayers, and communal gatherings. On the occasion of the festival, various embassies in Addis Abeba have extended congratulatory messages. The embassies of #Russia and the #United_States, along with those of #Germany, the #Netherlands, the #United_Kingdom, #Switzerland, #Sweden, #Finland, #Israel, #Armenia, #Canada, #Iran, #Pakistan, and #Australia, wished Ethiopians a peaceful and joyful celebration. (Source: FBC, TigTV)