Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
According to @/mkgenie, the president of Michael Jackson's Chinese fanclub, and that had access to the list of recording artists of the MJ tribute project in 2023, Jungkook was one of the renowned singers that would get to sing one of the 10 never-released song written by Michael Jackson along with Bruno Mars, Doja Cat and Sza!
#JUNGKOOK
•@OUR_7_PRINCES•
“Yes, Love him! Incredible! His dancing, singing, songs, incredible machine. I love that dude, like he’s incredible”
— Omar Rudberg, a Venezuelan-Swedish singer and actor, about #Jungkook
#JUNGKOOK
•@OUR_7_PRINCES•
Rolling Stone UK Twitter Update
Read the full interview with #JungKook here
https://www.rollingstone.co.uk/music/features/jung-kook-bts-interview-rolling-stone-photos-57298/
-@All_BTS_Updates
GameSpot, a major American website providing news & reviews about video games, wrote an article about #Jungkook
“BTS's Jungkook Is A Streamer Now, Here Are The Games He's Played So Far”
https://www.gamespot.com/gallery/btss-jungkook-is-a-streamer-now-here-are-the-games-hes-played-so-far/2900-7286/
#INFO
•@OUR_7_PRINCES•
Famous actor Manny Jacinto said #Jungkook was his bias in a recent interview for Cosmopolitan
Q: Recently, a photo of you at a j-hope concert made the internet rounds. Who is your BTS bias?
🗣️ “Jungkook. I was a dancer, and I have this theory. Jungkook apparently trained in Los Angeles when he was younger, and I think we almost crossed paths and trained in the same studio around the same time. I mean, he is, like, eight years younger than me, but I saw videos and pictures of him training at the same studio. And I was like, wait, when was this? And this was around the same time, like, summer of 2012, 2011. I think he’s one of the best dancers on the team. But I also just dig his music.”
#INFO
•@OUR_7_PRINCES•