Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
🪩Nick Fanciulli at Savaya Bali
📆 Sunday, 12 January
Nic Fanciulli is a respected figure in electronic music, recognised for his Grammy-nominated remix of Gorillaz's ‘Dare’ and for founding the influential Saved Records label. His credits include projects such as The Social festival with top artists, as well as appearances at venues such as Space Ibiza and Tomorrowland, cementing his legacy in the dance music scene.
🔍 Details of the event, as well as tickets, are available on the official website.
@BaliNews
#wheretogo#events#parties
🥳A four-day Halloween party in Kuta
🔔 Starting tomorrow, October 30, Old Man's will be hosting a series of Halloween parties starting at 5:00pm.
Come dressed to impress as your favorite ghoul, ghost, or Halloween character for a chance to win big in our spine-chilling costume contest.
🎫 Tables for one-day start from Rp2,400,000 – included entrance fee for 4 pax, 1 bottle of house pouring and 4 mixers.
👨💻 More information via the link.
@BaliNews
#wheretogo#parties#Kuta
🪩 There will be a party at Savaya on Saturday
ℹ️ Building upon her cultural heritage and her musical tastes (the artist grew up listening to artists such as Nina Simone, Bob Marley and Marvin Gaye), AWEN started to produce her unique style of Afro-house.
🧞♀️ It mixed electronic instrumentation with timeless melodies - and a touch of spirituality.
📲 More info and tickets (Rp 600,000) are here.
#wheretogo#parties#Badung@BaliNews
⭐️Electronic music star Boris Brejcha in Bali
📍 Savaya Bali
📆 May 18, 2005
⏰ Doors Open at 1:00 pm
🔞 Entry strictly 21+
🎟 Rp1,350,000
🪩 German DJ Boris Brejcha is known to all lovers of techno and mind-blowing parties. As part of his world tour he will be stopping by Bali.
🔎 More information and tickets here.
@BaliNews
#events#parties#Badung
🪩Morabito presents Bombossa Brothers
📍 Morabito Art Villa, Canggu
📅 Friday, February 28
⏰ 6:00 pm
Bombossa Brothers are twins with two interesting personalities and one mission: to entertain as many people as possible with their groovy melodic sound. Over the past couple of years, they have built up their reputation as a duo to watch by playing around the world and expanding their Momentum event series, hosting up to 2000 people in their hometown of Tallinn, Estonia.
🎫Tickets at the link from 250.000 IDR.
@BaliNews
#wheretogo#parties#Canggu