Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
Matthijs de Ligt:
“Since November I have done everything, pushing myself in every session and exploring every option, to get back to doing what I love, playing football.
“I am grateful to everyone who has supported me throughout a difficult period in my career. I remain as determined as ever to represent Manchester United and play in front of our incredible supporters as soon as possible.”
#MUFC [MU]
Matthijs de Ligt Ig: “After 6 months of treatment and working hard to get back, surgery was the only option left. I’m disappointed I couldn’t help the team the last 6 months and obviously missing out on the World Cup but I am looking forward to doing everything to get back in front of the fans and feeling better again 🙏🏼💪🏼” #MUFC
Matthijs de Ligt has undergone successful surgery to adress a back injury, say Manchester United.
They say De Ligt will begin a new phase of his recovery and is expected to return for United in the early stages of the 2026/27 season.
#MUFC
Michael Carrick has ACCEPTED #mufc's contract proposal! He will sign as head coach until 2028, with the option to extend for another season.
𝐇𝐄𝐑𝐄 𝐖𝐄 𝐆𝐎 ✅🏴
[Fabrizio Romano]
Michael Carrick on #mufc's future targets:
"You’ve got to aim upwards. That’s the beauty of football, beauty of competition to achieve something and back it up, that’s the challenge.
"For the players, for the squad, for the whole group and football club we want to keep moving in a positive way and in the right direction.
"The closer you get to the top the less room for progress, but progress is what we’re aiming for."
Jamie Carragher on his ‘leave football before it leaves you’ comments on Casemiro:
“In retrospect, do I regret my comments about such a legendary footballer? Yes and no. It must be acknowledged that the implication that Casemiro was 'finished' at the highest level was too harsh and premature.
“My argument was he would be better heading out to the MLS, or accepting offers from Saudi Arabia, because he would never get back to anywhere near his best to achieve the same heights of winning the Champions League or league titles at Old Trafford as he did so brilliantly at Real Madrid.
“At the time, those observations were not controversial. In 2024, Casemiro was unfit, lacked the physicality and athleticism to cope with quicker, sharper opponents, and was exposed when used in a deeper role, either in midfield or at centre-back as he was that night at Selhurst Park.
“This week, Casemiro suggested my remarks were 'disrespectful', and that is fair enough. Anything he says in response comes with the territory, although I would counter and say no disrespect was intended. Quite the contrary.
“Because of his stellar career, it was natural to compare Casemiro to the extraordinarily high standards he set for himself.” #MUFC [Telegraph]
📥@Manchester_Utdfc
🚨 Manchester United are proposing an initial TWO-YEAR contract offer to Michael Carrick until 2028!
Talks are now underway after co-owner Sir Jim Ratcliffe gave the go-ahead following an executive committee meeting this week where chief executive Omar Berrada and director of football Jason Wilcox made the recommendation for Carrick to get the job full-time 🔴 [Laurie Whitwell, The Athletic] #mufc
📥@Manchester_Utdfc
Michael Carrick’s backroom staff are expected to stay, with Steve Holland, Jonathan Woodgate and Jonny Evans all in line for new deals. Craig Mawson is also set to continue as first-team goalkeeping coach following his promotion after Ruben Amorim’s departure.
#mufc also want to add a set-piece coach, with Andreas Georgson, highly rated during his previous spell at United, among the contenders to return from Tottenham
[Laurie Whitwell]
📥@Manchester_Utdfc
Bruno Fernandes:
“I’ve always said, Declan Rice was a player to play for #mufc, I was really sad when he chose to go Arsenal.
“I always thought he would be a PERFRCT fit for our club.”
📥@Manchester_Utdfc
Excl: #MUFC plan to offer Michael Carrick an initial contract of 2 years until June 2028 with a 1 year option to extend. No formal negotiations have begun so no agreement yet. The 44 yo has been involved in recruitment meetings for the summer.
[Sully Talkz]
📥@Manchester_Utdfc