Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
🌎 Some mid-ocean ridges, like the Mid-Atlantic Ridge, are areas where new seafloor is constantly created as tectonic plates move apart. Hydrothermal vents along these ridges support unique ecosystems, including tube worms and giant clams, which thrive in total darkness using chemical energy instead of sunlight. ✨
#ocean⚡#geology⚡#biodiversity
👉subscribe Interesting Planet
👉more Channels
🌎 Deep beneath the Caribbean Sea, the deepest known blue hole—Dean’s Blue Hole—plunges over 200 meters. Its tight entrance leads to vast, vertical caverns, hosting unique marine life adapted to total darkness and low oxygen levels. ✨
#geology⚡#ocean⚡#biodiversity
👉subscribe Interesting Planet
👋😉 Barchaga salom!
🐳 Xalqaro bioxilma-xillik kunida Toshkentdagi BMTTD mamlakat ofisi "Eco-schools Uzbekistan" loyihasi ishtirokchilari uchun Ochiq eshiklar kunini o‘tkazdi.
🌲 BMTTD xodimlari bolalarimizga qiziqarli ekskursiya uyushtirib, o‘z ofisida qo‘llanilayotgan ekologik yechimlar va qiziqarli BIOFIN tashabbusi haqida ma’lumot berishdi hamda uning tabiatni asrash va tiklashdagi o‘rni haqida so‘zlab berishdi. Tadbir yakunida o‘quvchilar olingan bilimlarni mustahkamlash maqsadida viktorinada ishtirok etdi.
#EcoSchoolsUzbekistan#Biodiversity#BIOFIN
—
👋😉 Всем привет!
🐳 В Международный день биоразнообразия страновой офис ПРООН в Ташкенте провёл День открытых дверей для участников проекта Eco-schools Uzbekistan.
🌲 Сотрудники UNDP устроили нашим ребятам интересную экскурсию, рассказали об экологических решениях, которые уже применяют в своём офисе и об интересной Инициативе БИОФИН и какую роль она призвана играть в сохранении и восстановлении природы. А в завершении мероприятия школьники приняли участие в викторине, чтобы закрепить полученные знания.
#EcoSchoolsUzbekistan#Biodiversity#BIOFIN
🌐Zamin🌐Instagram🌐Facebook
The Hula painted frog—declared extinct, now rediscovered in 2011—is a true Lazarus and a living fossil. 🐸✨🌿🔬@googlefactss
[Read more]
#Conservation#LazarusSpecies#Biodiversity
Today we at @googlefactss present to you:
Alytes muletensis — the Majorcan midwife toad. First only known from fossils in 1977 and presumed extinct, live individuals were found in Mallorca three years later.
This tiny endemic lives only in Tramuntana mountain streams, where males carry and keep the eggs moist on their backs until they hatch. 🐸🌿
[Source]
@googlefactss
#conservation#biodiversity#LazarusSpecies
🌎 The saiga antelope’s enlarged, drooping nose acts as a built-in air filter and cooler on the Central Asian steppes. When alarmed, herds can stampede at speeds up to 80 kilometers per hour. ✨
#animals⚡#evolution⚡#biodiversity
👉subscribe Interesting Planet
👉more Channels
🌎 The shoebill stork stands over 1.2 meters tall and has a massive, shoe-shaped bill up to 24 centimeters long. Native to East African swamps, this solitary bird hunts lungfish, frogs, and even baby crocodiles. ✨
#animals⚡#biodiversity⚡#evolution
👉subscribe Interesting Planet
👉more Channels
🌎 In Slovenia, the Postojna Cave harbors a rare blind amphibian called the olm, which can live without food for up to 10 years. The cave stretches over 24 kilometers and contains vast chambers, underground rivers, and prehistoric animal remains. ✨
#geology⚡#caves⚡#biodiversity
👉subscribe Interesting Planet
👉more Channels
🌎 Beneath Borneo’s limestone hills, the Clearwater Cave system spans over 237 kilometers, making it one of the world’s largest interconnected cave networks. Its underground river flows for 11 kilometers, supporting unique species like blind catfish and swiftlets that nest in its dark chambers. ✨
#caves⚡#geology⚡#biodiversity
👉subscribe Interesting Planet
👉more Channels
🌎 The world’s deepest cave, Veryovkina Cave in Georgia, plunges to 2,212 meters below the surface. Its vertical shafts, tight squeezes, and frigid underground streams challenge expert cavers. Specially adapted crustaceans and fungi live in total darkness at these extreme depths. ✨
#caves⚡#geology⚡#biodiversity
👉subscribe Interesting Planet
👉more Channels
🌎 In Croatia’s Velebit Mountains, the Lukina Jama–Trojama cave system plunges over 1,431 meters deep, housing rare leech species and tiny amphipods. Exploring these deep caves requires specialized rope techniques and careful study of underground water flows, revealing new life forms adapted to total darkness and isolation. ✨
#caves⚡#biodiversity⚡#geology
👉subscribe Interesting Planet