Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
🤑Gate.io Startup Answer & Earn @walken_io💵
📝Take the quiz about Walken(WLKN) & Split a $3,000 mega prize!🏆
⏰Ends at 9:00AM, Jul 25th (UTC)
*How to participate:
✅ Join GateioOfficialNews and Walken community
✅Follow @Gateio_Startup & RT the 👉POST
🔛 Click 👉HERE to Participate now
Learn More:https://www.gate.io/startup
#Gateio#gateiostartup
📣Startup Voting Campaign #4 - $8,000 up for grabs
Vote for your favorite project by 6:00 AM, Sep 8 (UTC)!
🏆Winning projects will shine in the spotlight!
💎$BYIN$CEC$MAK$ANS
🔄Share to rally support for your pick!
👉Vote:https://gate.io/activities/startupvote?gt_disable_intercept_jump=1&now_period=5
#GateioStartup#Memecoins#Airdrop
📣Day 3 of voting! $8,000 up for grabs—vote for your favorite project by 6:00 AM, Sep 8 (UTC)!
🏆Winning projects will shine in the spotlight!
💎$BYIN$CEC$MAK$ANS
🔁Share to rally support for your pick!
👉Vote:https://gate.io/activities/startupvote?gt_disable_intercept_jump=1&now_period=5
#GateioStartup#Memecoins#Airdrop
🚀$8,000 up for grabs! #Vote for your favorite project by 06:00 AM, Sep 8 (UTC)!
$BYIN$CEC$MAK$ANS
🏆Winning projects get the spotlight
🔁Retweet to support your pick
Vote now:https://gate.io/activities/startupvote?gt_disable_intercept_jump=1&now_period=5
#GateioStartup#Memecoins#Airdrop
📈#Gateiopartner carnival: the main prize of $12,000 is being played out 🔥
The promotion is active until 11:00 Moscow time on February 24
ℹ️How to earn:
1) Registration on Gate + KYC2
2) Go here and click "Join now"
3) We complete the tasks:
🎁BONUS 1 : Registration + KYC, PrizeStartup voucher for 20 shares
🎁BONUS 2 : Make a deposit of $50, prize from $5 to $10
🎁BONUS 3 : Make a trading volume of $200, split the prize pool of $10,000 depending on the share in the total trading volume
🎁BONUS 4 : Invite users and share the prize pool of $2000
🔗Join now and earn: https://gate.io/fr/campaigns/396?ref=VLJMULHBVA
#Gateio#GateioStartup#Crypto
🚀Gate.io Startup Free Offering: Cat Gold Miner (CATGOLD)
🗓Subscription Period:06:00AM January 7 - January 9 (UTC)
💵Airdrop Amount: $50,000 CATGOLD
👉Sign up here
🔗
⏰Trading Starts:10:00,AM January 9 (UTC)
📚Full Details:Click here
🎉Gate.io New Year Red Envelope: Get a $60 bonus by following this link ➜ Red Envelope
⚡️Don’t miss this unique chance to accelerate your earnings with CATGOLD! Places are limited, register now and be among the first to take advantage of this exclusive offer! ⭐️
🔗gate.io
📈
#GateioStartup#Gateio#CATGOLD
💰Trade $HQ on Gate.io & Win Your Share of $4,000!
👀 A new trading event is live on Gate.io, giving you the chance to earn big rewards!
🗓Event Period: February 7 at 06:00 AM UTC - February 12 at 06:00 AM UTC
💰Rewards:
✅$3,000 Trading Bonus – Trade at least $50 in HQ and share a $3,000 prize pool.
✅$950 New User Bonus – New users who sign up and trade $10 in HQ will receive $10 instantly.
✅$50 Lucky Reward – 1 lucky participant from the comments will win $50!
⚠️Important:
✔️ Complete your identity verification before the event ends to qualify.
✔️ Rewards will be distributed in HQ within 14 working days.
✔️ No multiple accounts or fraudulent activity allowed.
🔥Join now and start trading! Don’t miss your chance to win big!
🔗Sign up & start trading here: https://www.gate.io/signup/?ref_type=103
#Gateio#GateioStartup#StartupMining#Launchpool#Launchpad