Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
HOW DUOLINGO’S AI LEARNS WHAT YOU NEED TO LEARN
DUOLINGO MAX
这篇文章提到了多邻国软件引入 AI 优化学习者体验。最近我也在高强度使用多邻国,分享下目前的语言学习路径(贴一下之前的语言学习小结及工具)。
1. 多邻国和视频入门阶段:主要是二外学习,可以直接多邻国熟悉单词以及部分语法,辅助以视频入门(可以不用跟随系统课程视频),能很好为一门新语言学习开路。
2. 整体文本摄入和沉浸处理阶段,比如 LingQ 软件的文章输入处理:主要是对成篇的文本沉浸处理,对更多新词和语法的慢慢熟悉和输入,不用太多。
3. 大量摄入阶段:可以直接大量摄入文章,量的输入。最近发现可以使用“沉浸式翻译”插件不断巩固语言,比如将法语翻译成英语等(多邻国学习类似)。
4. SRS 巩固内化阶段:通过间隔重复对重要单词及其句子进行巩固和内化,使用 Anki 或者 Supermemo 这些工具。当然,现在 AI 处理闪卡以及单词也更加方便,比如单词造句和分析都可以借助 AI 预处理一些,善用。
5. 3 和 4 阶段持续循环。
#language
A word you may not know, but certainly will make "some" people chuckle:
Tittynope (n)
tit-ee-n-oh-p
A small quantity of something left over. 🌚
@googlefactss
[Source]
#funfact#language
Errors in Go:
From denial to acceptance
Learn how to stop worrying and love error handling in Go. Author of Overmind and imgproxy describes his journey through all five stages of Kübler-Ross model—from denial to acceptance—as he went deeper into the language, and shares his favorite patterns for dealing with errors in Go code.
#development#language
https://evilmartians.com/chronicles/errors-in-go-from-denial-to-acceptance
Ok, I’m online again so Happy New Year for everyone 🎈
The first article that I want to share this year is about channels design in GoLang, their structure and internal operations. Enjoy the reading!
#development#language
https://codeburst.io/diving-deep-into-the-golang-channels-549fd4ed21a8
Hello, there! One GoLang feature proposal about immutability is here 🙂
It’s a really interesting idea with pros and cons inside, it has a good explanation, use cases and examples for the following proposed changes: fields, arguments, variables, return values, methods reference types (Pointers, slices, maps, channels). This approach merits attention if you are interested in paths of GoLang development, so, have a good reading! 😉
#language#development
https://github.com/romshark/Go-1-2-Proposal---Immutability
“Should I Rust, or Should I Go” - this is an article with a quick comparison of Golang and Rust code styles, features and conveniences of usage.
#language#development
https://codeburst.io/should-i-rust-or-should-i-go-59a298e00ea9
Good day 👋 I would like to share following 7 advices in short article by Kartik Khare how to increase your code quality in GoLang. Of course, before using it you should understand reasons for each advice in the post. As example Kartik writes:
#6 Use int as keys instead of strings in Map.
It’s a good way but here we can get optimization for optimization 🤔
#development#language
https://codeburst.io/how-to-optimise-your-go-code-c6b27d4f1452
Compare the hash-map implementation between different languages: Python, Ruby, Java, Scala, GoLang, C++ and C#.
Good analysis, enjoy reading!
#development#language
https://rcoh.me/posts/hash-map-analysis/