Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
#Vocabulary
🕸Dormant
🦦 (of an animal) having normal physical functions suspended or slowed down for a period of time; in or as if in a deep sleep
🫧 Ex:- During the winter months, the bears will often go dormant and hibernate.
🌨Basic Synonyms
🌓 asleep
🌓 slumbering
🌓 inactive
🌟Advanced Synonyms
✨ comatose
✨ supine
✨ lethargic
✨ torpid
✨ aestivating
🌔Antonyms
🍀 awake
🍀 wakeful
#Vocabulary
🎶Repertory2⃣
🎼a collection, especially of music or information
🎻 Ex:- This year, the Boston Philharmonic has expanded its repertory to include compositions from Mexico.
🎸Basic Synonyms
collection
#Vocabulary
🎨Repertory1⃣
🎭 the performance of various plays, operas, or ballets by a company at regular short intervals
Ex:- Martin was overjoyed when he learned his audition was good enough to get him accepted at the New York Repertory for Young Composers.
❄️Basic Synonyms
🫧 theater
🫧 troupe
🫧 school
#Vocabulary
📜 Screed
📝a long speech or piece of writing, typically one regarded as tedious
✍Example:-
When they lost the match, the team coach launched into an almost incoherent screed on all the areas the team had to improve in.
📒Basic Synonyms
🖌 rant
📔Advanced Synonyms
🖍 harangue
#Vocabulary
🥢Palatable
🍽(of food or drink)
pleasant to taste; has acceptable taste
🍴Example:-
Tonight, a surprisingly palatable spread will be laid out on the table. Don't be shy — come.
🧉Basic Synonyms
🥤 tasty
🥤 eatable
🍹Advanced Synonyms
🧋 appetizing
🧋 edible
🧋 savoury
🧋 delectable
🧋 luscious
🧋 flavourful
🧃Antonyms
🫗 distasteful
🫗 unsavoury
#Vocabulary
💡Mellifluous
/məˈlɪflu.əs/, /mɛˈlɪflu.əs/
⚜Sweet or musical; pleasant to hear.
💥Her mellifluous voice captivated the audience during her performance.
#Vocabulary
🔸Cacophony
⚜A harsh, discordant mixture of sounds.
💥 The cacophony of honking cars and
shouting pedestrians filled the streets of the busy city.
#Vocabulary
🌺Diffident.
●Lacking or marked by a lack of self-confidence; shy and timid, distrustful of one's own powers.
●He was diffident about his own success.
●Because she was only a first-year student, she was diffident when offering a comment on the professor's lecture.
#Vocabulary
🌺Spurious
/ˈspjʊəriəs/ 《adjective》
●a spurious statement, argument etc is not based on facts or good thinking and is likely to be incorrect.
▪️He demolished the opposition’s spurious arguments.