Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
‘Sharing is off the table’ as #drought reshapes the lives of #Ethiopia’s pastoralists
Pastoralists in Ethiopia’s #Somali region say that worsening drought is eroding traditional systems of sharing that once helped communities survive.
Historically, Somali pastoralists survived drought through strong social networks. These Indigenous climate adaptations were built on an intricate system of mutual aid.
One of the most important systems is known as Gergar, a form of social insurance in which families who lose livestock receive animals from relatives and neighbors to help rebuild their herds.
“When people used to lose livestock, others would help them,” says Mohamed Abdi, a lifelong pastoralism advocate and director at Jijiga University’s Institute of Pastoral and Agro-Pastoral Development Studies. “We would move to relatives or sub clan areas, and they shared water and pasture with us.”
https://news.mongabay.com/2026/04/sharing-is-off-the-table-as-drought-reshapes-the-lives-of-ethiopias-pastoralists/
'Our children are next' fear #Kenyans as #drought wipes out livestock
In drought-hit northeastern Kenya, villagers have been forced to drag their dead livestock to distant fields for burning to keep the stench of death and scavenging hyenas away from their homes.
Mandera county along Kenya's borders with Ethiopia and Somalia has seen no rain since May and is now on the point of a full-blown water emergency.
"I have lost all my cows and goats, and burned them here," Bishar Maalim Mohammed, 60, a resident of Tawakal village, told AFP.
In his village, where most are pastoralists relying heavily on their animals, the only remaining bull can no longer stand. He has lain in the same spot for nearly a week, severely dehydrated with bones protruding through his skin, as his owner watches helplessly.
https://addisstandard.com/?p=55089
🌎 The Madagascan baobab, sometimes called the “upside-down tree,” stores thousands of liters of water in its massive trunk, allowing survival through severe drought. This clever reservoir keeps it lush while nearby plants wilt. ✨
#Madagascar⚡#baobab⚡#drought
👉subscribe Interesting Planet
Northern Kenya drought pushes millions to hunger
The lack of rain in northern Kenya means 2.4 million people in the region will struggle to find enough to eat by November, the United Nations World Food Programme says.
#News#Reuters#Kenya#drought#food#environment
Subscribe: http://smarturl.it/reuterssubscribe
Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled.
Get the latest news on: http://reuters.com/
Follow Reuters on Facebook: https://www.facebook.com/Reuters
Follow Reuters on Twitter: https://twitter.com/Reuters
Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en
➖@reutersworldchannel➖
U.N. warns of Madagascar 'climate change famine'
Madagascar produces less than 0.01% of global carbon dioxide emissions, but amid a fourth year of drought in the Grand Sud region, the U.N. is warning of a 'climate change famine'.
#Madagascar#UN#UnitedNations#ClimateChange#ClimateChangeFamine#GrandSudRegion#Drought#News#Reuters
Subscribe: http://smarturl.it/reuterssubscribe
Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled.
Get the latest news on: http://reuters.com/
Follow Reuters on Facebook: https://www.facebook.com/Reuters
Follow Reuters on Twitter: https://twitter.com/Reuters
Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en
➖@reutersworldchannel➖