Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
🇺🇸#LosAngeles. Wild teens ransack Chevron store in Lincoln Heights in broad daylight.
Another SoCal store is taken over by rampaging teens racksacking aisles, grabbing whatever they can. This time, a Lincoln Heights Chevron station is hit. The frustrated store managers who want police to do more to stop the takeovers.
Follow us -> LiveLeak
Please do not curse the victims of the American fires. There are many innocent civilians and pro-Palestinian people. Those elites had already fled before the fires came.
#LosAngeles
This is absolutely disgusting and heartbreaking.
Homeless addicts on Skid Row in LA are using innocent dogs to test their drugs for fentanyl. These poor animals are being fed deadly substances, abused, neglected, sold for drugs, and thrown away like trash.
Volunteers from Starts With One Today are risking their lives to rescue these dogs with zero support from the city.
How has Mayor Karen Bass and LA leadership let this horror continue? Animals are suffering and dying in plain sight while officials do nothing.
This is pure cruelty. Where is the outrage? Where is the action?
#SaveSkidRowDogs#AnimalAbuse#LosAngeles
🔹👉🏻@SherriTenpenny
PERFECT RING FORMED OVER LOS ANGELES
This appeared high above L.A. just after dusk.
A bright linear trail stretched across the sky — and around it, a smooth circular arc expanded and held its shape.
The symmetry is what stands out.
A straight line through the center.
A clean curve wrapping around it.
It lingered long enough for people across the city to stop and stare.
Los Angeles, California.
Did you catch this from where you are?
MrMBB333
👇 Drop your city.
#MrMBB333#SkyWatch#LosAngeles
#Wildfires ravage #California, leaving 5 people dead and over 27,000 acres burned. #LosAngeles Authorities warned casualties may rise as the fires remain uncontained.
USA Major League Soccer🇺🇸
2026-04-19 23:00 UTC
Los Angeles FC vs. San Jose Earthquakes
Predicted outcome: Los Angeles FC❌
Predicted score: 2:1
Actual: San Jose Earthquakes 1:4
#LosAngeles#SanJoseEarthquakes
#Football#USAMLS
As #LosAngeles burns and #firefighters face a severe water crisis, criticism is mounting against #billionaires Stewart and Lynda #Resnick, whose $13B agricultural empire consumes more water than LA and SF combined.
#PalisadesWildFire
USA Major League Soccer🇺🇸
2026-05-10 20:30 UTC
New York City FC vs. Columbus Crew
Predicted outcome: New York City FC✅
Predicted score: 3:2
Actual: New York City FC 3:0
#NewYorkCity#ColumbusCrew
2026-05-10 23:00 UTC
Minnesota United FC vs. Austin
Predicted outcome: Minnesota United FC❌
Predicted score: 2:1
Actual: Draw 2:2
#MinnesotaUnited#Austin
2026-05-11 01:00 UTC
Los Angeles FC vs. Houston Dynamo
Predicted outcome: Los Angeles FC❌
Predicted score: 2:1
Actual: Houston Dynamo 1:4
#LosAngeles#HoustonDynamo
#Football#USAMLS