Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
#vlog
Forgot to share the vlog here! With exams approaching days are going even faster and tomorrow is already December!
While trying to study hard, I am also working on my skills and my side projects. Love college, love life, love my family and friends. And of course love you!
~ 🤓~
↬@jastm1🐰
#vlog
New week, new vlog🍎😁
Did u miss me? I was away during the weekends…
Courses are getting harder and it’s getting harder to film vlogs but I am trying to make them as good as possible 😬
~🐈~
↬@jastm1🌊
#vlog
✨ Another little glimpse into my day ✨
Yesterday was packed with challenges - from a dentist appointment to preparing for upcoming quizzes. It was long, it was busy, and yes, I ended the day completely exhausted. 💗
But here’s the thing: every busy day is also a step forward. Each challenge we push through is shaping us, teaching us resilience, and bringing us closer to our goals. 🎀
So if you’re also feeling tired from studying, working, or just managing life, remember, it’s all part of the journey. Keep going, because the effort you’re putting in today will turn into tomorrow’s growth. 🍵🤩
Let me know if you want more vlogs like this🤎
~🐈~
↬@jastm1🌊
#vlog
Yesterday was a very colorful, interesting, and tiring day. The first day of September turned out pretty productive! I woke up early and prepared for my classes (Algorithms, to be exact
😶). We had a very challenging Algorithms class — I could literally feel my brain frying 😀. Our professor is really funny though, with a Russian accent.
Then I had another class - a core course called Chance. Honestly, I’d call it “a chance for a good sleep.” We have a lovely French professor who’s over 70 and speaks very quietly and slowly
🥲. And since the class is at 2 p.m., you can imagine…
After that class, I was ready to go to my Jiu Jitsu training, but it got canceled. So instead, I helped out at the Student Fest, where all the clubs at our uni gathered to present themselves. Our Central Asian Student Association was there too, and it was so much fun! Everyone waited for somsa and chebureki... I got to meet many new freshmen, and they were super friendly. One of them even turned out to be subscribed to my channel - such an honor honestly
⭐.
So yeah, the day was so tiring it felt like Friday. My roommate and I couldn’t even wake up early today :)
~🐈~
↬@jastm1🌊
#vlog
I am back with another cute vlog 🥰
It was filmed like a week ago. Hope you will enjoy it.
These weeks are very busy and I am filming another long and funny vlog for you! Hopefully I will have time to edit it 🥲
#vlog
My daily routine at university. Everyday is the same :wake up -> eat ->study and that's on repeat.
Right now I am trying to learn and apply as much knowledge as I can, building the necessary foundation for the future internships (hopefully).
Also watching anime about pharmacy girl in ancient times, I LOVE IT 😊.
Yesterday I freaked out and had a good cry because of my cs assignment, but then managed to somehow finish it by 2 am. Now the most challenging part is left - DEBUGGING.
Alhamdullilah for such stability 🍵
~🍋~
↬@jastm1🌊