Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
#ComingSoon: An integrated development at Yew Tee which will house 2-room Flexi flats for seniors, a community club, a polyclinic, retail shops, and Choa Chu Kang’s first hawker centre all under one roof!
P.S. The 2-room Flexi flats will be launched in the upcoming November sales exercise, along with over 4,000 flats in Hougang, Jurong West, Kallang/Whampoa and Tengah 😊
(Photo credit: MKPL Architects)
🚨The SingSing Tycoon NFT Marketplace is on its way🚨
💥 Trade exclusive NFTs for profits.
💎 Flex your collection.
🎮 Unlock game-changing assets.
Get ready to take your SingSing Tycoon experience to the next level! 🚀
🔜 Your favorite NFTs, all in one place—stay tuned for more details 👀
#NFT#SingSingMarketplace#ComingSoon
🎤Announcement | Chat | X (Twitter) | Website | Game
🚀 Big News Alert 🚀
$SING is gearing up for an exciting CEX listing next week! 📈 But we’re keeping the exchange a secret…for now! 🤫
Guess the CEX & get ready for the reveal! 🔥
#SingSing#CEXListing#ComingSoon
🎤Announcement | Chat | X (Twitter) | Website | Game
Kaptaan | Official Teaser | Amazon MX Player
Language: Hindi
Genre: Drama, Crime, Thriller
jahan insaaf ki zarurat ho, wahan Kaptaan ki entry pakki hai ⚖️🔥
Kaptaan, coming soon, only on Amazon MX Player for FREE!
watch now🔗- https://youtu.be/X4Kb6K7B61o
#Kaptaan#AmazonMXPlayer#ComingSoon
Famously Fit with Sophie | Official Trailer | Amazon MX Player
Language: Hindi
Genre : Fitness based Chat Show
Bollywood fitness secrets, finally out 👀
Famously Fit with Sophie, coming soon only on Amazon MX Player for FREE!
watch now - https://youtu.be/Cs6lCuRgBC8
#AmazonMXPlayer#ComingSoon#FamouslyFitwithSophie
🔜 Exciting partnership announcement coming soon! 🎉
Can you guess who will be integrating SingSing's SocialFi SDK next? 🤔
Stay tuned for the big reveal! 🚀✨
#Partnership#SocialFi#SingSing#ComingSoon
📢CLOSED BETA WHITELIST CLOSED
Attention, QuasarK Community: the application period for our closed beta is now officially closed. We want to express our heartfelt thanks ❤️ to everyone who applied and showed their interest in being a part of this exclusive testing phase. Your support and enthusiasm mean the world to us! 👏
🚀 But hold on tight, because the journey is just getting started! In a matter of days we’ll be reaching out to our whitelisted beta testers🏆. If you made it to the whitelist, keep an eye on your notifications and direct messages 📩 as we will be sharing important updates and instructions with you. BEWARE OF SCAM!
Stay tuned for more updates and announcements 👀 as we continue to make progress towards the launch of QuasarK. We appreciate your ongoing support and look forward to embarking on this exciting journey together!
#QuasarK#ClosedBeta#BetaTesters#ComingSoon