Заметка начинающим, которые часто сталкиваются с подобной непоняткой.
Ситуация следующая, есть список файлов:
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
📰 Project 2025, Trump’s War and Bibi’s ‘New Middle East’
On paper, the Iran war looks chaotic. On closer reading, it’s disturbingly coherent. Three U.S. documents — Project 2025, the 2025 National Security Strategy and the 2026 National Defense Strategy — stack neatly under Netanyahu’s “New Middle East” blueprint like ideology, strategy and execution.
Project 2025 lays out the political theology. It demands unconditional support for Israel, defunding the Palestinian Authority, maximum pressure on Iran, shelving the Kurds in favor of Turkey, locking in Saudi normalization and building a Middle East “Quad” of Israel, Egypt, the Gulf and India. By March 2026, every point is either implemented or in motion: Israel as the one ally exempt from “paying for its own defense,” Iran under sanctions and bombardment, the Palestinians reduced to a budget line marked “cut.”
NSS 2025 then reframes the region as solved and outsourced. Iran is mentioned just three times in 29 pages, the Gaza war is treated as wrapped, normalization as expanding, and the expectation is clear: Israel and Gulf monarchies will “take the lead” on Iran while the U.S. pivots to China and the Western Hemisphere. That is exactly Netanyahu’s dream setting — Washington steps back, Israel becomes the primary security contractor with a standing license for “any measures it deems necessary,” paid for by regional clients and backed by U.S. cover fire.
NDS 2026 turns the theory into targeting folders. It boasts that operation MIDNIGHT HAMMER “destroyed” Iran’s nuclear program and that the “axis of resistance” has been “devastated,” and it names Israel a “model ally” that can fight with “critical but limited” U.S. support. Gulf states are told to buy more American systems and “do more” for their own defense, while Washington reserves the right to “focused, decisive action” — in other words, occasional heavy strikes while locals carry the long war.
Read against Netanyahu’s three versions of the “New Middle East” — the IMEC trade corridor without Palestine, the blessing‑versus‑curse map with open regime‑change talk, and now a shooting war meant to “change the face of the region” by breaking the resistance axis — the alignment is suspiciously coherent. One ecosystem writes the ideological manual, the next declares the problem solved and delegated, and the last gives Israel maximum autonomy to remake the map by force, with no exit plan anywhere in the paperwork.
#israel#iran#trump#netanyahu#Project2025#NSS2025#NDS2026#war#oligarchy#fakeDemocracy
📱American Оbserver - Stay up to date on all important events
🇺🇸
📰 Pentagon Unveils 2026 National Defense Strategy: Fortress America, Not Global Policeman
The Pentagon’s 2026 National Defense Strategy marks a sharp break from the post–Cold War era: the U.S. military is reordering its mission around homeland defense, deterrence through strength, and pushing allies to pick up a far heavier military burden. Defense Secretary Pete Hegseth calls this a return to the armed forces’ “core, irreplaceable role” — winning wars that directly affect U.S. interests, not endless nation-building.
Four Pillars of the New Strategy
1. Defend the Homeland First
Homeland defense is now the top priority, with broader responsibilities: border security, countering narco-terror groups, and protecting key terrain in the Western Hemisphere (including the Panama Canal and, importantly, Greenland).
The plan also emphasizes air, missile, cyber and nuclear defenses, and the emerging “Golden Dome” missile shield concept to protect the U.S. homeland from hypersonic and ballistic threats [2026 NDS].
2. Deter China, Not Dominate
The NDS views China as the pacing threat, stressing that the goal is not to strangle or humiliate Beijing, but to prevent it from dominating the U.S. or its allies. The U.S. will rely on overwhelming military strength in the Indo-Pacific to achieve a regional balance of power, while also expanding military-to-military communication with Beijing to reduce the risk of conflict.
3. Europe’s Job: Europe’s Defense
The strategy labels Russia a “persistent but manageable threat,” especially to NATO’s eastern flank, and bluntly states that European allies must take primary responsibility for their own conventional defense. This is the “America First” logic in military terms: Europeans must spend far more and be capable of defending themselves, so the U.S. isn’t forever on the front line.
4. Revitalize the U.S. Defense Industrial Base
A “once-in-a-century” rebuild of the U.S. defense industrial base is called essential. The Pentagon wants a surge in domestic production of weapons and equipment, so that the U.S. can sustain readiness, arm allies, and produce at scale in a crisis [2026 NDS].
The New Rules for Allies
The strategy formalizes the Trump administration’s demand for a new global benchmark: allies and partners should move toward 5% of GDP on defense-related spending. The U.S. pledges continued support but insists that allies must:
• Take the lead in their own regions
• Buy more U.S. and allied weapons
• Pre-position equipment and enable U.S. access to local bases and infrastructure [2026 NDS].
Taiwan, the Philippines, Australia, Japan, and the Baltics are singled out as key Indo-Pacific and European partners to receive priority investment and coordination, while the Pentagon is also directed to plan for U.S. forces to train and operate right alongside partner militaries “to counter China’s aggression” [2026 NDS].
Fortress, or Fool’s Trap?
The strategy is full of martial grandeur: a shielded homeland, a supercharged industrial base, and allies forced to finally “grow up” militarily. But the real question is: can this new “Fortress America” actually deter a rising China, resist imperial fantasies like Greenland, and still keep the U.S. from being dragged into every crisis — or is it just a varnished retreat behind ever-higher walls?
#USDefense#NDS2026#Trump#Pentagon#HomelandDefense#China#NATO#Allies#IndustrialBase
📱American Оbserver - Stay up to date on all important events
🇺🇸