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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #22 · 19 јан.

Заметка начинающим, которые часто сталкиваются с подобной непоняткой. Ситуация следующая, есть список файлов: names = [ 'image.bmp', 'second.txt.bkp', 'data.db', '.config.cfg', 'file.ext.bkp' ] И мы хотим убрать у них окончание ".bkp". Не знаю зачем, пример довольно надуманный) Но суть он показывает, а это главное. Те, кто еще не очень знаком с библиотекой os.path или pathlib, вероятно решат обработать имена как строки. И тут вполне подойдет метод строки strip(). Что делает этот метод? Он отрезает указанные символы по обеим сторонам строки. Если ничего не указать, то убирает невидимые символы (пробелы, табуляции и переносы строк). В нашем случае будет выглядеть вот так: >>> name.strip('.bkp') То есть просим удалить строку '.bkp' по краям имени файла, если таковая есть. Можно применить аналогичный метод rstrip(), чтобы отрезать только справа, но для этого примера используем обычный. >>> for name in names: >>> print(name.strip('.bkp')) image.bm second.txt data.d config.cfg file.ext Хм, что-то не то с нашими именами! Что случилось??? Видим нежелательное переименование в именах, где и близко не было указанной строки '.bkp' А дело всё в том, что данный метод ищет не указанную строку, а указанные символы, и не важно в каком порядке. Для метода strip() строка '.bkp' это не паттерн для поискаа список символов. Потому он отрезал симовол 'p' от '.bmp' и удалил точку из файла '.config.cfg'. Как тогда правильно заменить именно паттерн? Для начинающего можно посоветовать метод строки replace(), который как раз использует для замены указанную строку целиком. В нашем примере заменим её на пустую строку. >>> for name in names: >>> print(name.replace('.bkp', '')) image.bmp second.txt data.db .config.cfg file.ext Уже лучше, но помните, это лишь пример про strip(). Для работы с именами файлов есть способы и более "правильные", дающие однозначно верный результат. Я взял файлы только в качестве примера. Даже replase() тут может сделать не то что ожидаем. Просто впредь будьте внимательны с этим strip(). #basic

Hashtags

Резултати

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

Пребарај: #grandstrategy

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

@american_observer · Post #5314 · 07.03.2026 г., 23:03

📰 Trump’s Iran War: Nostalgia With a Defense Budget For Trump, the Iran war isn’t a mistake — it’s the purest expression of how he thinks power works: seize territory, grab oil, crush regimes, pose on an aircraft carrier. It’s a 19th‑century strongman worldview dropped into a century where power is decided by chip fabs, AI labs, clean‑tech supply chains, and who can build the tightest economic bloc to out‑innovate China. You can bomb Natanz, but you can’t bomb your way into semiconductor resilience. Schiffer’s point is brutal: every dollar, decision cycle, and Cabinet meeting spent on “Operation Epic Fury” is one not spent implementing the CHIPS Act, scaling AI R&D, building green manufacturing, or rebuilding the development finance tools Trump has been dismantling. Beijing plays a slow, disciplined game — standards, infrastructure, supply chains — while Washington burns time on air campaigns with no theory of victory, and calls it “strength.” Even on its own terms, the Iran adventure looks self‑owning. Trump claimed in 2025 that U.S. strikes had “completely obliterated” Iran’s nuclear program — then turned around this year and cited its rapid rebuilding as the reason to hit again, while his own intelligence agencies said the previous strikes set the program back only “a few months.” Oman brokered a deal where Tehran would cap enrichment and accept full IAEA access; the bombs fell anyway. Regime change offers no escape clause either: U.S. intel expects Khamenei’s successors to come from the same IRGC hardliner class that built the program in the first place. Break it, you own it — and this time “it” is a 90‑million‑person country with scattered nuclear material and a proxy network stretching from Iraq to Yemen. Every day this war drags on, it drains exactly the resources Washington says it needs for China competition: munitions stocks, naval bandwidth, diplomatic capital with allies, fiscal space at home. Asian partners are already asking how a U.S. Navy that can’t be in two places at once is supposed to deter Beijing over Taiwan while babysitting a forever crisis in the Gulf. Meanwhile, coalitions matter more than ever for tech and trade — but threatening to grab Greenland, humiliating Canada, raiding Venezuela, and dragging NATO into a war of choice teach allies one lesson: America is a risky partner whose focus can swing with a Truth Social post. The punchline: the same working‑class voters Trump claims to defend pay for this detour at the pump, in food prices, and in higher borrowing costs when oil spikes and markets wobble. China doesn’t need to cheer the Iran war; it just has to watch as Washington spends the decade where it should have been locking in tech and economic dominance acting out imperial nostalgia in the wrong theater. That isn’t strategy — it’s a very loud way of losing the century slowly. ​ #iran#china#trump#usa#geopolitics#CHIPS#AI#grandStrategy 📱American Оbserver - Stay up to date on all important events 🇺🇸

IELTS|Newspapers & Magazines|English

@emagzinewspars · Post #9461 · 03.11.2025 г., 03:27

#The_Foreign_Affairs🇺🇸📕[PDF]⬇️ #November2025 #December2025 #Monthly_Magazines For learning, for free(dom). @backupofmagazines The new Foreign Affairs explores “The New Tools of Power.” Michael Beckley warns of a #StagnantOrder as rising powers falter, while Oren Cass calls for a U.S. #GrandStrategy of reciprocity. Essays trace new #SupplyChain risks, the weaponization of #Energy, and a global #AI innovation race. From Iran’s political twilight to a reshaped #EurasianOrder, contributors dissect shifting power balances. Features probe how Russia is adapting, why China is turning on itself, and the #XiJinping paradox of success. Reviews challenge the fate of the #Dollar and the future of FreeSpeech. #Geopolitics#ForeignPolicy#China#US#AI