Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
#MyGov पल्स - सिटीजन कनेक्ट पाक्षिक न्यूज़लेटर के इस अंक में 2023 में भारत की ऐतिहासिक उपलब्धियों और #ViksitBharat की दिशा में प्रगति से संबंधित उपलब्धियों को जानें।
पूरा पढ़ें: https://static.mygov.in/static/s3fs-public/mygov_170349057782937911.pdf
जिन मुद्दों को दशकों तक किया गया नजरअंदाज, प्रधानमंत्री नरेंद्र मोदी के नेतृत्व में बीते 10 वर्षों में उनका हुआ कायाकल्प। आइए देखें...
#PMModi#NewIndia
#ViksitBharat
We got this, and #ViksitBharat is all about it!
Don’t miss this week’s #FridaysAtMyGov to see young minds sharing their vision for #NewIndia 2047 and how, with government support, they are flexing their skills to build the future they want
To watch the full episode, visit: https://www.youtube.com/watch?v=mmZFDtR_LrE
सहकारिता - विकसित भारत की असली ताकत!
खेती, डेयरी, बैंकिंग, बीज, निर्यात और सेवाओं तक; सहकारिता का मॉडल किसानों, कामगारों और ग्रामीण भारत को सशक्त बनाकर ‘सहकार से समृद्धि’ की राह को मजबूत कर रहा है।
आइए इस 🧵 द्वारा जानें: https://x.com/i/status/2030890080014156147
#SahkarSeSamriddhi#ViksitBharat
This week, MyGov India hosts Soumitra Dutta, professor at the University of Oxford and author of 'From Gridlock to Growth: How Leadership Enables India's Pragati Ecosystem to Power Progress'.
Explore how PRAGATI has transformed the delivery of major infrastructure projects and propelled India’s progress to new heights.
Don’t miss this opportunity to gain valuable insights into the transformative journey of #NewIndia!
Watch the full episode: https://youtu.be/VTp4fv1H31k
#PRAGATI
#ViksitBharat
What’s India saying about AI? Let’s find out! 🎤🇮🇳
Join us for this week’s #FridaysAtMyGov as people share their experiences with AI’s growing influence in India
Watch the full episode now:
https://youtu.be/_OIwATkwTUU
#AI
#ViksitBharat
#IndiaRising
All aboard the future of rail travel!🚆
This #FridaysAtMyGov, experience the engineering marvel #VandeBharat Express, now connecting Delhi to Srinagar under the visionary #MakeInIndia initiative. Ready to tackle snow, designed for comfort, and built for innovation, it's a symbol of #ViksitBharat in motion.
Watch the full video now: https://www.youtube.com/watch?v=LmufFHQY2gc
#NewIndia
NRIs aren’t just Indians abroad—they’re Bharat’s global power. #PravasiBharatiyaDivas celebrates this unbreakable bond.
A day that honours the spirit of NRIs, proving that distance can never weaken their connection with Bharat
Watch their inspiring journeys and hear their views on Bharat’s global rise under PM Narendra Modi’s visionary leadership
🎥 To watch the full video, visit: https://youtu.be/-g65oAFX5Yg?si=n1XUY7r1c66BnkRs
#ViksitBharat
#NewIndia
#PBD2025
5 Crore Voices. 5 Crore Dreams. 5 Crore Saathis.
MyGov.in, launched by PM Narendra Modi, has achieved the incredible milestone of reaching 5 crore subscribers! 🎉
Thank you to every Saathi for being a part of this vibrant community! Let's continue to engage, inspire, and shape a #ViksitBharat together.
#5CroreSaathis
#MyGovSaathis
#NewIndia
'करेंगे और कर के रहेंगे' विकसित भारत का संकल्प!
On August 9, 1942, we united with a powerful resolve for freedom.
#QuitIndiaMovement#UnityInStrength#TransformingIndia#ViksitBharat
Get ready for another thrilling episode of Fridays At MyGov!
Join us as we take you inside the cutting-edge Namo Bharat Rapid Train, redefining travel with its air-conditioned, secure, and modern features. It's not just a ride—it's an experience of convenience and innovation!
Watch the full episode: https://www.youtube.com/watch?v=2DOooLw01bo
Stay tuned for more episodes celebrating Viksit Bharat.
#FridaysAtMyGov#ViksitBharat#NamoBharat#RapidRail