Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
Gatto Channel: June Events Calendar
#calendar#events
Gatto | Official Channel (18+) has released a calendar of regular events for June. Collaborations, raffles, and secret events are not listed, requiring subscribers to stay tuned for further announcements.
Source: link
@tonlines
In 46 BC, Julius Caesar added 90 extra days to the year, making it 445 days long. This was done to fix the calendar’s drift from the solar year. The previous calendar was out of sync with the seasons. Caesar introduced the Julian calendar, which included leap years every four years to keep the calendar aligned with the sun.
📅🔧
[Read more]
@googlefactss
#History#Calendar#LeapYear
🌍 Samoa famously skipped December 30, 2011, to switch from the eastern to the western side of the International Date Line. This move aligned its calendar with Australia and New Zealand. ✨
#Samoa⚡#dateline⚡#calendar⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
📅 Calendar Stickers 📅
https://telegram.me/addstickers/Calendar2016
#Calendar#Useful#Hacks
🛠 It could be useful (or even some sort of a lifehack) for users.
Fokus
To Do app tailored specifically for #students
Fokus is an open source application that combines a #todo list and a #calendar that can help you manage your #school related #work and #events in one place. It's fast and beautiful yet simple design that can help you focus on what matters most.
Features:
• Get reminded when a task is nearing its due
• Get reminded about incoming events
• Add attachments to your tasks
• Persistent notifications for important tasks or events
• No ads or any tracking
• Open Source Code
• On-Device Database
Download: https://github.com/icabetong/fokus-android/releases/
https://github.com/icabetong/fokus-android
@foss_Android