Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
Mirror, mirror on the wall, who's the most #HDBeSavvy of them all? 👑✨ Swipe for info on buying an HDB flat and start your home-buying journey strong. Psst… our next BTO launch drops this July!
#HDBeSavvy and check out this guide to priority schemes that can improve your chances when balloting for a flat in BTO/SBF exercises 😊
📖 Read our guide to priority schemes
👀 Check out our guide to CPF housing grants
Eyeing a resale flat? #HDBeSavvy and use these resources to:
📝Check your eligibility to buy a resale flat and apply for an HDB housing loan
📊View resale statistics (e.g. median resale prices by town and flat type)
📍Check if an HDB flat is within 4km of another residential property to qualify for the Proximity Housing Grant
📥Apply to buy a resale flat via the HDB Resale Portal
📚Sign up for our resale seminars to learn more about resale policies and procedures
Read more about resale flats:
◾️Your Guide to Buying a Resale HDB Flat
◾️Buying a Resale Flat: What to Look Out For
ICYMI, check out our resource kit on financial planning.
Working out the math for your flat?
#HDBeSavvy and use these resources to:
💰Calculate your budget
📥Apply for an HDB Loan Eligibility Letter (HLE)
📋Compare loan packages offered by participating Financial Institutions (FIs)
📑View the customised payment plan for your homebuying journey
Read more about financial planning:
◾️How to decide between a loan from HDB and a loan from an FI
◾️A guide to CPF Housing Grants
Planning to buy a 3-room flat in this sales exercise? We’ve done the math for you so you can #HDBeSavvy in planning your finances 🤓
🔗 If you need more help, visit https://homes.hdb.gov.sg/calculator
Choosing among the 4,501 BTO flats on offer across 6 locations? #HDBeSavvy by comparing your options!
P.S. You can also tap on the Enhanced Housing Grant of up to $80,000 to finance your flat purchase, depending on your income.
Other resources:
🧐Study the flats/location on offer, and their estimated completion dates
📝Check your eligibility
💰Work out your budget
Find out more about the differences between buying a BTO and resale flat under the Singles Singapore Citizen Scheme in our #HDBeSavvy cheatsheet! ➡https://t.me/SingaporeHDB/775
Planning to buy a 3-room flat in this sales exercise?
We’ve done the math for you so you can #HDBeSavvy in planning your finances 🤓
🔗 Visit https://homes.hdb.gov.sg/calculator to calculate your own flat budget, including housing loan estimates from HDB and participating financial institutions!
🍋 When life gives you lemons… here are 4 #HDBeSavvy things to do while waiting for your BTO flat to be ready.
🔗#DYK? Average waiting time for ongoing BTO projects, including pandemic-induced delays, has remained between 4 to 5 years.
Planning to #BTOgether at the upcoming Sales Launch? #HDBeSavvy and use these resources to:
📝Check your eligibility to buy a BTO flat and/or apply for an HDB housing loan
🗺View the locations on offer at upcoming Sales Launches via the HDB Flat Portal
Read more about BTO flats:
▪️A Guide to Buying a BTO Flat
▪️Expenses First-Timer BTO Flat Buyers May Overlook
▪️HDB Does Not Price Flats to Recover Land and Building Costs
ICYMI, check out our resource kits on financial planning and resale flat buying.
Received the keys to your new flat and can’t wait to start designing your dream home? From designing your kitchen island, to choosing the right lights and TV consoles, or even ideas on baby-proofing, here are resources that can help you #HDBeSavvy:
💭 Be inspired by design ideas, including our curated list of IG accounts to follow for interior design inspo
🔎 Explore our HDB showflats at our virtual My Nice Home Gallery
👀 Peek into home tours by fellow HDB residents
Now that you have #saidyes to your new home design, we also have tips on how to maintain your home after move-in.