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 слични објави

Пребарај: #ism

当前筛选 #ism清除筛选
Shadow Traders Fx

@shadowtraderfx · Post #4326 · 03.11.2025 г., 11:38

📰Top News and Events for the Upcoming Week (November 4–10 November, 2025) for Gold and Forex Hey traders! 👋 This week, gold and forex markets are centered on major US data including ISM Services PMI, trade balance, jobless claims, and factory orders, plus RBA rate decision and Eurozone inflation figures. With Fed policy in spotlight post-PCE, sticky inflation could delay cuts and strengthen USD, capping gold upside. Yet, dovish surprises or global weakness (e.g., soft Eurozone) may revive safe-haven demand. Key pairs like EUR/USD, GBP/USD, and USD/JPY face swings from central bank signals and jobs previews. Here’s a day-by-day breakdown for your trades – let’s get ready! 📈 ✉️Follow @shadowtraderfx for more! ✅ Tuesday, November 4, 2025 📎Gold: US ISM Services PMI (10:00 ET) kicks off – contraction below 50 boosts safe-haven flows, lifting gold. 📎Forex: PMI impacts DXY; weak reading favors EUR/USD and GBP/USD gains. USD/JPY steady amid yen caution. Key event: ISM Services PMI – a miss weakens USD majors. 💡 Tip: Mid-morning volatility; enter on confirmed breaks. ✅ Wednesday, November 5, 2025 📎Gold: US Trade Balance (8:30 ET) and JOLTS Job Openings (10:00 ET) in focus – wider deficit or high openings signal labor strength, pressuring gold via USD resilience. 📎Forex: JOLTS drives jobs narrative; strong print drops EUR/USD support. GBP/USD eyes UK data spillover. Key event: JOLTS Job Openings – above forecasts bolsters USD. 💡 Tip: Labor data overlap – tighten stops for whipsaws. ✅ Thursday, November 6, 2025 📎Gold: RBA rate decision (overnight) and US initial jobless claims (8:30 ET) dominate – steady RBA with dovish tilt weakens AUD, supporting gold; rising claims erodes USD. 📎Forex: RBA impacts AUD/USD heavily; claims lift majors like EUR/USD. USD/JPY risks yen rebound on risk-off. Key event: US Initial Jobless Claims – rise fuels Fed cut bets. 💡 Tip: Asia-US session bridge – watch for RBA presser cues. ✅ Friday, November 7, 2025 📎Gold: Eurozone CPI Flash (5:00 ET) and US factory orders (10:00 ET) wrap week – hotter Euro inflation pressures ECB, indirectly aiding gold; weak US orders boost dovish vibes. 📎Forex: CPI moves EUR/USD; soft factory orders weaken DXY. GBP/USD consolidates; USD/JPY eyes BoJ fallout. Key event: Eurozone CPI Flash – above target caps euro rally. 💡 Tip: Month-start flows – scale out early to manage gaps. ✅ Saturday & Sunday, November 8–9, 2025 (Markets Closed) 📎Gold & Forex: Digest RBA, US jobs data, and Euro CPI. Forecast: Gold gains on dovish signals; DXY dips if claims rise. 💡 Tip: Review for next week’s FOMC minutes and CPI. ✅ Monday, November 10, 2025 📎Gold: US wholesale inventories (10:00 ET) starts fresh – buildup hints at economic slowdown, lifting gold as safe-haven. 📎Forex: Inventories subtle for DXY; EUR/USD tests recent highs. Low-volume pre-major events. Key event: US Wholesale Inventories – surprise drawdown supports USD. 💡 Tip: Quiet open; position for mid-week catalysts. 🔎 Weekly Summary: ISM Services, JOLTS, and RBA decision lead – strong US labor data could hawkish-shift Fed expectations, strengthening USD, but weak Euro CPI fuels gold rallies. Forex pairs volatile, so risk management! Join us winning team 💬 📱Stay updated with @shadowtraderfx #Gold#Forex#ISM#RBA#CPI#XAUUSD#EURUSD