Armin dislikes new PEP regarding structural pattern matching https://twitter.com/mitsuhiko/status/1359263135304187910
btw PEP has been approved!
https://www.python.org/dev/peps/pep-0636/
btw PEP has been approved!
https://www.python.org/dev/peps/pep-0636/
Twitter
Armin Ronacher
I really, really, really don't want to be dismissive of all the new python language features but it's hard not to see faults in PEPs like this: https://t.co/fIvSTSEcxl — pattern matching is awesome, but only when the language is built for it.
I can't recall where I saw this originally, but you can use the spaceship operator "--0--" to turn floor division into ceiling division:
>>> 12//5
2
>>> --0-- 12//5
3
There's also the ++0++ operator when you want to emphasize that you really *do* mean floor division:
>>> ++0++ 12//5
2
from https://bugs.python.org/issue43255#msg387248
But yes, -(-n // d) is the easy (if a little bit cryptic) way to get the ceiling of n / d.
>>> 12//5
2
>>> --0-- 12//5
3
There's also the ++0++ operator when you want to emphasize that you really *do* mean floor division:
>>> ++0++ 12//5
2
from https://bugs.python.org/issue43255#msg387248
But yes, -(-n // d) is the easy (if a little bit cryptic) way to get the ceiling of n / d.
🇺🇦 Python Programming Сhallenges
I can't recall where I saw this originally, but you can use the spaceship operator "--0--" to turn floor division into ceiling division: >>> 12//5 2 >>> --0-- 12//5 3 There's also the ++0++ operator when you want to emphasize that you really *do* mean floor…
It's just a trick
It's because unary minus is right-associative and binds tighter than binary minus which is left-associative
-12 // 5 => - 3
- (-12 // 5) => +3
The rest is just putting 0 at the start:
--0 == 0
and --0--12//5 is parsed as
-(-(0)) - (- (12 // 5))
from Twitter https://twitter.com/ericpromislow/status/1362475189125095425?s=21
It's because unary minus is right-associative and binds tighter than binary minus which is left-associative
-12 // 5 => - 3
- (-12 // 5) => +3
The rest is just putting 0 at the start:
--0 == 0
and --0--12//5 is parsed as
-(-(0)) - (- (12 // 5))
from Twitter https://twitter.com/ericpromislow/status/1362475189125095425?s=21
Twitter
ericpromislow
@professorcraven @VictorStinner @nedbat It's just a trick It's because unary minus is right-associative and binds tighter than binary minus which is left-associative -12 // 5 => - 3 - (-12 // 5) => +3 The rest is just putting 0 at the start: --0 == 0 and…
Forwarded from 🇺🇦 Go for two :)
Performance comparison: counting words in Python, Go, C++, C, AWK, Forth, and Rust
https://benhoyt.com/writings/count-words/
https://benhoyt.com/writings/count-words/
Benhoyt
Performance comparison: counting words in Python, Go, C++, C, AWK, Forth, and Rust
Performance comparison of counting and sorting word frequencies in various languages (Python, Go, C++, C, AWK, Forth, and Rust)
blue is a somewhat less uncompromising code formatter than black, the OG of Python formatters.
https://github.com/grantjenks/blue
https://github.com/grantjenks/blue
GitHub
GitHub - grantjenks/blue: The slightly less uncompromising Python code formatter.
The slightly less uncompromising Python code formatter. - grantjenks/blue
https://talkpython.fm/episodes/show/332/robust-python is a really interesting episode, and resonates really strongly with me for how to write good/maintainable/robust code
talkpython.fm
Robust Python
Does it seem like your Python projects are getting bigger and bigger? Are you feeling the pain as your codebase expands and gets tougher to debug and maintain? Patrick Viafore is here to help us write more maintainable, longer-lived, and more enjoyable Python…
Forwarded from 🇺🇦 Go for two :)
How to Make Your Code Reviewer Fall in Love with You:
1. Review your own code first
2. Write a clear change list description
3. Automate the easy stuff
4. Answer questions with the code itself
5. Narrowly scope changes
6. Separate functional and non-functional changes
7. Break up large change lists
8. Respond graciously to critiques
9. Be patient when your reviewer is wrong
10. Communicate your responses explicitly
11. Artfully solicit missing information
12. Award all ties to your reviewer
13. Minimize lag between rounds of review
https://mtlynch.io/code-review-love/
1. Review your own code first
2. Write a clear change list description
3. Automate the easy stuff
4. Answer questions with the code itself
5. Narrowly scope changes
6. Separate functional and non-functional changes
7. Break up large change lists
8. Respond graciously to critiques
9. Be patient when your reviewer is wrong
10. Communicate your responses explicitly
11. Artfully solicit missing information
12. Award all ties to your reviewer
13. Minimize lag between rounds of review
https://mtlynch.io/code-review-love/
mtlynch.io
How to Make Your Code Reviewer Fall in Love with You
Best practices for code review when you're the author.
Forwarded from 🇺🇦 Go for two :)
A_cheeky_way_to_check_if_an_expression_is_not_one_of_two_constants.png
110.5 KB
>>> a = 2
>>> a != 2 != 3
False
>>> a != 2 != 3
False
@oleg_log just remind me regarding to repost
https://www.djangoproject.com/weblog/2021/sep/21/django-40-alpha-1-released/
https://www.djangoproject.com/weblog/2021/sep/21/django-40-alpha-1-released/
tip: how to convert audio to text
Using #Python pydub and speed_recognition to convert audio to text:
https://twitter.com/bbelderbos/status/1442519795761549325
Using #Python pydub and speed_recognition to convert audio to text:
https://twitter.com/bbelderbos/status/1442519795761549325
Twitter
Bob Belderbos
Using #Python pydub and speed_recognition to convert audio to text:
Python behind the scenes #13: the GIL and its effects on Python multithreading
https://tenthousandmeters.com/blog/python-behind-the-scenes-13-the-gil-and-its-effects-on-python-multithreading/
https://tenthousandmeters.com/blog/python-behind-the-scenes-13-the-gil-and-its-effects-on-python-multithreading/
Tenthousandmeters
Python behind the scenes #13: the GIL and its effects on Python multithreading
As you probably know, the GIL stands for the Global Interpreter Lock, and its job is to make the CPython interpreter thread-safe. The GIL allows...
Forwarded from 🇺🇦 Go for two :)
FA3t6syVgAo40X8.jpeg
50.2 KB
LOL😭😭😭
Someone nuked the DNS A and AAA records for Facebook, Instagram, and WhatsApp Face with hand over mouth
Someone nuked the DNS A and AAA records for Facebook, Instagram, and WhatsApp Face with hand over mouth