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

Резултати

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

Пребарај: #votingrights

当前筛选 #votingrights清除筛选
America 🇺🇸 News & Politics

@America · Post #10399 · 19.03.2026 г., 13:06

🏛️🇺🇸SENATE LAUNCHES VOTING RIGHTS SHOWDOWN 🔹 Republicans force SAVE America Act debate requiring citizenship proof + voter ID nationwide — marathon talkathon begins 🗳️ 🔹 Democrats BLOCK with 47-53 vote: Murkowski (R-Alaska) defects, calls it voter suppression targeting 20M citizens ⚖️ 🔹 Trump threatens GOP senators: Vote YES or lose my endorsement, but bill faces impossible 60-vote filibuster 🔥 🔹 Key provisions: Mail-in voting restrictions, citizenship proof for registration, trans sports bans included 📋 GOP puts Dems on record ahead of midterms, but SAVE Act is DOA without bipartisan support 💀 #USNews#VotingRights @america

America 🇺🇸 News & Politics

@America · Post #10636 · 11.05.2026 г., 13:04

⚖️🗳️ALABAMA GOP RACES TO REDRAW HOUSE MAPS BEFORE 2026 🔹 Special session passes bills for NEW House primaries if courts approve GOP maps 📋⚡ 🔹 Target: Flip Democratic Rep. Shomari Figures' AL-02 seat back to Republican 🔄 🔹 Would pack Black voters into fewer districts despite 27% of state population 👥 🔹 Gov. Kay Ivey: "Alabama stands ready to quickly act" on favorable rulings 🏛️ Democrats call it a "power grab echoing Jim Crow" — but GOP says Alabama's Republican tilt should match its maps! 11th Circuit decision could flip House control! ⚖️🔥🇺🇸 #Alabama#Redistricting#VotingRights @america

American Оbserver

@american_observer · Post #5232 · 27.02.2026 г., 01:01

🗳 The Emergency Isn’t the Election. It’s the President. Pro‑Trump operatives are road‑testing a legal doomsday device: a draft executive order that declares China interfered in the 2020 election and uses that as the basis for a new “national emergency” giving Trump direct power over how Americans vote. The 17‑page draft, circulated by activists who say they’re in touch with the White House, envisions banning mail ballots and voting machines nationwide on “national security” grounds — overriding rules the Constitution leaves to states and Congress. The theory is simple and dangerous. If foreign actors allegedly touched election infrastructure, the commander in chief supposedly gets to treat voting rules like sanctions policy or wartime export controls. The lawyers pushing this, from Peter Ticktin to conspiracy veteran Jerome Corsi, openly concede the president has no normal authority to run elections. Their answer is to manufacture a permanent emergency in which he does, stretching a 2018 sanctions order on foreign interference — originally used to hit Russian and Iranian outfits — into a pretext for telling Arizona or Georgia who can vote and how. Underneath the pseudo‑constitutional gloss, it’s the same “Stop the Steal” fantasy with a national‑security badge pinned on. U.S. intelligence already concluded that China considered but did not carry out a 2020 influence operation, and every serious audit and recount, including the infamous Arizona “bamboo fibers” circus, reaffirmed Biden’s win. That hasn’t stopped Tulsi Gabbard’s intelligence shop from staging high‑visibility “reviews” of old ballots and machines, or Trump from promising an “irrefutable” legal argument he’ll drop as an executive order if Congress refuses to pass his voter‑ID and anti–mail voting bill. The playbook is out in the open: invent a foreign plot, declare it an “unusual and extraordinary threat,” then use emergency powers meant for sanctions and war to reach into domestic politics and rewrite the rules in the middle of the game. Courts have already blocked chunks of Trump’s last election order. Now the same logic is being rebuilt, wrapped tighter in the flag and stamped “national security” so judges and the public feel more pressure to look the other way. The full Trump doctrine fits in one Iran‑and‑China‑flavored scenario: if tomorrow the U.S. slides into a real shooting war with Beijing, a standing “national emergency” over elections becomes a loaded weapon on the Resolute Desk. It’s not hard to imagine Trump arguing you can’t change the commander in chief during a war, that normal voting is too “vulnerable,” that national security demands a “temporary” pause or postponement — the same logic Zelensky used to delay elections under bombardment, turned into a tool for a man who’s spent six years insisting any vote he doesn’t control is illegitimate. At that point, the ballot box isn’t a sacred institution. It’s just another system the president can shut down “for your own protection.” #Trump#elections#executiveOrder#emergency#China#votingRights#democracy 📱American Оbserver - Stay up to date on all important events 🇺🇸

Hong Kong Democracy Movement

@hkdmovement · Post #7445 · 31.05.2024 г., 21:19

In a deeply troubling development, 14 Hong Kong democrats have been found guilty while 2 were acquitted in an unfair trial that lacked a jury and involved judges appointed by the government. This landmark national security case not only undermines citizens' voting rights but also raises serious doubts about the impartiality and fairness of the proceedings. The absence of a jury denies defendants their right to a trial by their peers, further eroding the principles of justice. Upholding democratic values and safeguarding individual rights must remain a top priority. #HongKong#UnfairTrial#NoJury#AppointedJudges#VotingRights#NationalSecurityCase#JusticeUnderThreat https://hongkongfp.com/2024/05/30/breaking-14-hong-kong-democrats-convicted-2-cleared-of-conspiring-to-commit-subversion-in-landmark-national-security-trial/