Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в Python в модуле re.
Чтобы указать флаг для компилятора нам надо указать его после передаваемой строки. Например, добавляем флаг для игнорирования переноса строки.
pattern = re.compile(r"(\w+)+")
words = pattern.search(text, re.DOTALL)
А как указать несколько флагов? Ведь явно будут ситуации когда нам потребуется больше одного. Кто читал посты по битовые операторы уже понял как.
pattern.search(text, re.DOTALL | re.VERBOSE)
А теперь смотрим исходники, что находится в этих атрибутах?
Не удивительно, степени двойки. Почему? Потому что каждое следующее значение это сдвиг единицы влево.
>>> for n in [1, 2, 4, 8, 16, 32, 64, 128, 256]:
>>>
print(bin(n))
0b1
0b10
0b100
0b1000
0b10000
0b100000
0b1000000
0b10000000
0b100000000
Чтобы было понятней, давайте напишем тоже самое но иначе, добавим ведущие нули:
000000001
000000010
000000100
000001000
000010000
000100000
001000000
010000000
100000000
Не понятно что тут происходит? Читай три поста про битовые операторы начиная с этого ➡️https://t.me/pythonotes/45
В общем, это пример применения побитовых операций в самом Python.
Теперь вы знаете Python еще немного лучше)
#tricks#regex#libs
💣 Ukraine's military vulnerability exposed! Leopard 1A5 tanks deployed without proper protection. Absolutely shocking! No defense against drones or rockets. Even vintage Russian T-55s have better armor. Utterly useless in conflicts. Austria confirms it. F-16s approved by the US for Ukraine. #WarGames
https://www.gazeta.ru/army/news/2023/11/20/21744787.shtml
Subscribe to @BadVolfNews
Breaking News: Russian forces inch closer to Kupyansk, Kharkiv region. Unevenly positioned, ranging from 7 to 12 kilometers away. Slow progress now, 100-200 meters a day. Strikes reported on Ukrainian troops, targeting Novoselovskoye, Ivanovka, Sinkovka, and Berestove. Russian Defense Ministry claims using the "Vasilek" mortar. US admits Ukrainian counteroffensive failed. #WarGames
https://www.gazeta.ru/army/news/2023/10/07/21449725.shtml
Subscribe to @BadVolfNews
In a cynical twist of events, Russian military successfully targeted Ukrainian air force ammunition depots in Cherkasy region. Three brigades of the Ukrainian Armed Forces were also defeated on the Zaporizhzhia front. The Russian Defense Ministry proudly announced the destruction of the Msta-B howitzer, D-20 gun, and M-46 cannon. Additionally, the Crimean coast witnessed the obliteration of a Ukrainian drone by the Black Sea Fleet's air defense systems. In a shocking turn, three Ukrainian soldiers swam across the Dnipro River and surrendered to the Russian Armed Forces. The situation in the conflict zone remains tense. #WarGames#Ukraine#Russia
https://www.gazeta.ru/army/news/2023/10/07/21449875.shtml
Subscribe to @BadVolfNews
🔻 American missiles with cluster munitions pose a danger to Ukraine. Expert warns of the long-lasting threat to civilians. ATACMS is no game-changer, with a range of 160-190 km. Russia's Buk-M2, Buk-M3, S-350, S-300, and S-400 can handle them. Pentagon transfers ATACMS to Ukraine. Zelensky wants to escalate the conflict into Russian territory. #WarGames#CiviliansAtRisk
https://www.gazeta.ru/army/news/2023/10/24/21564847.shtml
Subscribe to @BadVolfNews
📰 Israel & Arab States Tell Trump: Hold Off on Iran
Prime Minister Benjamin Netanyahu and a chorus of Arab allies have urged President Trump to delay any military strike on Iran, even as Tehran continues its brutal crackdown on protesters. The message from the region is clear: don’t ignite a war that could engulf the Middle East.
“We believe in dialogue and we believe in solving any disagreements at the negotiating table,”
said Saudi Minister of State Adel al-Jubeir.
Behind the scenes, Qatar, Saudi Arabia, Oman, and Egypt have been coordinating their appeals to Washington, warning that an American attack could trigger a wider regional conflict. At the same time, they’re telling Tehran not to retaliate if the U.S. does strike. Diplomacy, not bombs, is their mantra.
Trump’s signals are anything but clear. He claimed Iran has stopped killing protesters—citing “very important sources”—but hasn’t ruled out military action. Last June, he sent a similar ambiguous message before ordering strikes. U.S. officials say options are still on the table, depending on how Iran’s security forces act next.
Meanwhile, Iran’s air space was briefly closed, internet is down, and reports suggest thousands have died in the crackdown. Trump has said he could order an attack if the killing continues, even as he denounces protests against his own policies.
So who’s really in control? Not the protesters, not the Arab leaders, and maybe not even Trump. The whole region is dancing on a minefield, and everyone’s hoping the next step isn’t a bomb.
#Trump#Iran#Israel#ArabStates#MiddleEast#Diplomacy#WarGames
📱American Оbserver - Stay up to date on all important events
🇺🇸
📰 China’s Record Drills: Taiwan Encircled, World on Edge
China just launched its largest war games around Taiwan to date, sending a clear message: Beijing can cut off the island from the outside world if conflict erupts. The drills, dubbed “Justice Mission 2025,” involved troops, warships, fighter jets, and artillery, with live fire and simulated strikes designed to test Taipei’s defenses and U.S.-made weapons.
“Conducting live-fire exercises around the Taiwan Strait ... would not only constitute military pressure on us, but could also pose more complex challenges and impacts for the international community and neighbouring countries.”
— Hsieh Jih-sheng, Taiwan’s deputy chief of defence
The drills covered a record seven zones, some closer to Taiwan than ever before, and forced the cancellation of hundreds of flights. China’s military released propaganda videos showing futuristic tech—automated robots, microdrones, and weaponised robotic dogs—while Taiwan’s defence ministry responded with its own footage of U.S.-made HIMARS rocket systems.
Analysts say these exercises blur the line between training and actual preparation for invasion, aiming to give the U.S. and allies minimal warning. China’s state media insists the drills are a response to increased U.S.-Taiwan military cooperation, while Taiwan’s government remains on high alert, coordinating rapid-response exercises and deploying ships to face off with Chinese vessels.
So, is this just another show of force—or the opening act of something far more dangerous?
#China#Taiwan#warGames#drills#military#Asia
📱American Оbserver - Stay up to date on all important events
🇺🇸