
On Tue, 22 Aug 2023 at 05:34, Wes Turner <wes.turner@gmail.com> wrote:
On Sat, Aug 19, 2023, 7:27 PM Celelibi <celelibi@gmail.com> wrote:
2023-08-04 8:18 UTC+02:00, Daniil.arashkevich@gmail.com <Daniil.arashkevich@gmail.com>:
Currently in Python we have construction like this:
tt = 5 while t: # do something tt -= 1
It would be great if in Python we have something like this: tt = 5 while (tt--): # do something
It is exists in C++. And in my opinion it is very Pythonic
Just as a reminder of C/C++: {pre,post}-{inc,dec}rementations bring their lot of issues with the language. Mostly the infamous *undefined behavors*. If you've done some C or C++ this very expression might send shivers down your spine.
From "Increment (++) and decrement (--) operators should not be used in a method call or mixed with other operators in an expression" https://rules.sonarsource.com/cpp/RSPEC-881/ :
We already know that C programmers are unnecessarily scared of a construct that, in Python, would not be scary. Anyway, rules like that have nothing to do with undefined behaviour, they could just violate a style guide. For example, https://rules.sonarsource.com/cpp/RSPEC-1774/ is a completely arbitrary style rule. And https://rules.sonarsource.com/cpp/RSPEC-1712/ enforces duplicate functions rather than using argument defaults. And https://rules.sonarsource.com/cpp/RSPEC-1142/ and, excuse me, https://rules.sonarsource.com/cpp/RSPEC-909/ ?? Yeah, I don't think this is anything more than a style guide. ChrisA