Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
#WellnessWednesday: Your health is your greatest asset.
Regular physical activities strengthens your heart, boosts your mood, improves productivity, and helps prevent chronic diseases.
✅ 30 minutes of exercise daily can make a big difference.
Make movement a priority today. Stay active. Stay healthy.
#WellnessWednesday#HealthyLiving#NCDCNigeria
#WellnessWednesday: Your health is your greatest wealth.
Stay active
➡️Drink Enough water
➡️Reduce sugar intake
➡️Aim for at least 7–8 hours of sleep daily
➡️Eat more fruits and vegetables.
Small healthy habits every day leads to a stronger, happier you.!
#WellnessWednesday#HealthyLiving#NCDCNigeria
#WellnessWednesday
Your wellness is your greatest achievement ✅
Eat well, Move often, Get enough rest and Protect your Peace !
Consistency builds a healthier you!!!
#WellnessWednesday#HealthyLiving#NCDCNigeria
#WellnessWednesday
⚡️Maintaining good health starts with simple, consistent habits.
Regular exercise, adequate rest, hydration, and a balanced diet help strengthen both body and mind.☑️
Make wellness a daily priority, small actions lead to lasting health.👍
#WellnessWednesday#HealthyLiving#NCDCNigeria
#WellnessWednesday: Your health journey starts with you!
💦Water is essential for your body and mind to function at their best.
Stay hydrated throughout the day and aim for at least 8 cups of water per day.✅
Small sips, big difference!
#HealthyLiving#WellnessWednesday#NCDCNigeria
#WellnessWednesday: Sleep Smarter, Wake Brighter
Good sleep is just as important as healthy eating and exercise.
Prioritise rest, aim at least 8hours of quality sleep and create a calm routine for a healthier you. 💤
#HealthyLiving#WellnessWednesday#NCDCNigeria
#WellnessWednesday: The Power of Good Hygiene
Good hygiene is your first line of defense against infections and diseases!
✅ Wash your hands often with soap under clean running water
✅ Keep your surroundings tidy
✅ Cover your mouth when you cough or sneeze
✅ Don’t share personal items
✅ Practice proper food hygiene
Small actions can make a big difference in protecting your health ✔️
Stay Healthy, Stay Safe!
#HealthyLiving#WellnessWednesday#NCDCNigeria
#WellnessWednesday:
Take time today to recharge👌
✨Your health is your greatest investment, make choices that helps you feel stronger, calmer, and more balanced every day.
#HealthyLiving#WellnessWednesday#NCDCNigeria
#WellnessWednesday: Fuel your body, calm your mind 🌱
True wellness goes beyond just eating right or exercising — it’s about finding harmony between your body and your mind. When you give your body the right nutrients, plenty of water, rest, and movement, you’re not only building strength but also creating the foundation for mental clarity and peace. 🙌
🧘🏾♀️A calm mind reduces stress, sharpens focus, and helps you show up fully in every area of life.
#HealthyLiving
#WellnessWednesday#NCDCNigeria
#WellnessWednesday: Eat better, Live better!
👉 Eating healthy isn’t about restriction, it’s about making smarter choices every day- choosing the right foods that helps fuel your body and mind✔️
Here are some tips on how to eat healthy👇🏿
➡️Eat the rainbow: Fill your plate with colorful fruits and veggies. Each color brings unique nutrients.
➡️Go whole, not processed: 🌾 Whole grains, beans, nuts, and fresh produce keep your energy steady.
➡️Healthy fats matter : Avocados, olive oil, and fish support your heart and brain.
➡️Stay hydrated: Water helps your body absorb all the goodness from food.
➡️Mindful eating: Slow down, chew well, and enjoy every bite.
✨ Eat smart, Stay strong, Live well!
#WellnessWednesday#HealthyLiving#NCDCNigeria
#WellnessWednesday: Simple Stress management Tips
Small daily habits can make a big difference for your health! 🌿
✅ Eat a balanced diet rich in fruits & vegetables
💧 Stay hydrated
✍️ Work smarter not harder
🏃♀️ Move your body daily, even with light exercise
😴 Prioritize 7–9 hours of quality sleep
🧠 Take time to relax, rest your mind and manage stress
Your health is an investment — care for it today for a stronger tomorrow. 💪
#WellnessWednesday#HealthyLiving#NCDCNigeria
#WellnessWednesday: Your Health, Your Priority!
Wellness isn’t a one-time goal, it’s a lifestyle and a continuous journey. Each day gives us an opportunity to make small but powerful choices that strengthen our body, calm our mind, and nourish our soul. 🧘♀️
Prioritize your health — eat nourishing meals, stay active, rest well and protect your mental health 🧠.
✅ Stay consistent
✅ Listen to your body
✅ Make your health a priority
#WellnessWednesday#HealthyLiving#StaySafe#NCDCNigeria