Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
Oil Market Balance May Return by April
An increase in traffic through the Strait of Hormuz by 5–6 tankers daily could restore market balance. Despite the London insurance market halt, up to 42% of the fleet under Liberia, Marshall Islands, Malta, and Bahamas flags are shifting to Chinese and Indian state guarantees. Panama and Singapore’s flexible fleets adapt faster, while Iran and Hong Kong’s “shadow fleet” bypass sanctions and remain active.
#oil#market#sanctions#Russia#maritimetraffic
The main news of Russia and the world ishere.
🚀 Increase in Ship Traffic Through Strait of Hormuz Observed
On April 10, the number of ships passing through the Strait of Hormuz increased to nine, according to data from shipping intelligence company Kpler. According to BlockBeats, this marks a rise from the previous day's count of five vessels, although it remains below the broader normalized levels.
#Shipping#StraitOfHormuz#MaritimeTraffic#Kpler#BlockBeats
🚀 Strait of Hormuz Traffic Halts Following U.S. Maritime Blockade
All maritime traffic through the Strait of Hormuz has reportedly ceased after U.S. President Donald Trump declared a maritime blockade via social media. According to NS3.AI, information from British sources, as reported by CCTV News, indicated that the blockade had been in place for several hours. While traffic was still feasible on the 12th, at least two vessels attempting to exit the strait reversed course. Tanker traffic had seen a slight uptick on the 11th before declining on the 12th.
#StraitOfHormuz#MaritimeBlockade#USPresident#DonaldTrump#TankerTraffic#CCTVNews#NS3AI#MaritimeTraffic
🚀 Iran Considers Bitcoin Toll for Ships in Strait of Hormuz
Iran is contemplating a new toll system for ships passing through the Strait of Hormuz, potentially requiring a $1-per-barrel fee payable in Bitcoin. According to NS3.AI, Hamid Hosseini, spokesperson for Iran’s Oil, Gas, and Petrochemical Products Exporters’ Union, indicated that this move could significantly impact maritime traffic. Arkham, a maritime analytics firm, estimates that a typical cargo ship carrying around 3 million barrels would face a payment of approximately $3 million in Bitcoin. Martin Kelly, head of advisory at maritime intelligence group EOS Risk, noted that this regulation could reduce the number of ships allowed to pass through the strait to 10–15 per day, a sharp decrease from the current average of about 135 ships.
#Iran#Bitcoin#Toll#StraitOfHormuz#Shipping#MaritimeTraffic#Oil#Cryptocurrency#Petrochemical#MaritimeRegulation#BTC
🚀 WTI Crude Oil Rises 10% Amid U.S.-Iran Peace Talks Stalemate
WTI crude oil experienced a significant intraday increase of 10%, reaching $105.33 per barrel, following the conclusion of the initial round of U.S.-Iran peace talks in Islamabad, which ended without an agreement. According to NS3.AI, the U.S. Central Command announced plans to block all maritime traffic to and from Iranian ports starting at 2:00 p.m. UTC on April 13. The U.S. military clarified that vessels traveling through the Strait of Hormuz to non-Iranian ports will not encounter any restrictions.
#WTI#CrudeOil#USIranPeaceTalks#MaritimeTraffic#Iran#StraitOfHormuz#USTechnology#NS3AI#CentralCommand#OilPrices