Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
#Antimicrobials are not always needed when you are feeling unwell.
Antibiotics should only be prescribed by healthcare professionals after an appropriate diagnostic test.
Be an #AntimicrobialResistance guardian.
#Antimicrobials are not always needed when you are feeling unwell.
Antibiotics should only be prescribed by healthcare professionals after an appropriate diagnostic test.
Be an #AntimicrobialResistance guardian
#Antimicrobials are not always needed when you are feeling unwell.
Antibiotics should only be prescribed by healthcare professionals after an appropriate diagnostic test.
Be an #AntimicrobialResistance guardian
#Antimicrobials are not always needed when you are feeling unwell.
Antibiotics should only be prescribed by healthcare professionals after an appropriate diagnostic test.
Be an #AntimicrobialResistance guardian
#Antimicrobials are vital in fighting infectious diseases across humans, animals, and plants.
However, their effectiveness is diminishing, leading to a growing and urgent crisis known as #AntimicrobialResistance.
Let’s promote the responsible use and work together to combat #AMR.
#Handwashing is a basic and effective tool against infections.
If we do not become sick, we would not need to use #antimicrobials.
Encourage your loved ones to practice frequent #handwashing with soap under running water.
Do your part to prevent #AntimicrobialResistance
#Antimicrobials are becoming less effective against common infections in animals & humans.
🚫 Do not self-medicate
✅ Visit a healthcare professional when sick
Everyone has a role to play to ensure #antimicrobials continue to work.
#AMR#WAAW2023
#AntimicrobialResistance is a global concern affecting everyone, everywhere, including users & non-users of #antimicrobials
Our National Action Plan for Antimicrobial Resistance incorporates a #OneHealth approach to contain #AMR in Nigeria
Read & share:
https://ncdc.gov.ng/themes/common/docs/protocols/77_1511368219.pdf
#AntimicrobialResistance is one of the top 10 health threats in the world.
Everyone everywhere, including users and non-users of #antimicrobials have a role to play to prevent #AMR.
#BeAntimicrobialAware
Every year, the National Antimicrobial Resistance Technical Working Group joins the global community to raise awareness of the dangers of misuse or overuse of #antimicrobials.
Fighting #AMR is a global endeavour that must be addressed through a #OneHealth approach as evident in this year's theme of #WAAW2023: ‘Preventing #AntimicrobialResistance together”
🔗Press Release
https://ncdc.gov.ng/news/504/nigeria-joins-the-global-community-to-commemorate-world-antimicrobial-awareness-week-%28waaw%29
Misuse or overuse of #antibiotics💊 & other #antimicrobials can reduce its effectiveness in treating common infections in animals & humans.
From 18th-24th November, we are joining the global health community to mark the annual #WorldAntimicrobialAwarenessWeek2022 .
#StayTuned
#AntimicrobialResistance is when medicines like #antimalarials, tetracycline, septrin, and amoxicillin no longer treat diseases they cured previously.
Everyone everywhere, including users and non-users of #antimicrobials has a role to play to prevent #AMR.
#BeAntimicrobialsAware