I am a complete noob at programming and Python in particular, and am JUST HAVING FUN. I’m sure there are a million things wrong with this (as I have been aggressively told by Reddit) but, just for shits and giggles, I want to make a suggestion. I hope you don’t mind.
Right now, we have
variable += value which, of course, is the same as
variable = variable + value
Changing the notation to
=variable + value doesn’t change any of the characters and so, it probably doesn’t really impair readability in any way once you get used to it. So why not use this second notation to EXTEND this functionality?
This would make the following possible, for example:
= (variable + 30) * 5/100
EDIT: and the result always gets evaluated and assigned to the only variable that can be included in the expression, even if it is repeated multiple times. This would allow for more complex operations while having the same exact benefit of not having to type the same variable once.
In fact, outside of production (I am aware it’s bad practice) it could even be used to do something like
moderately_long_variable_name = re.search('pattern', source_text) if moderately_long_variable_name: = moderately_long_variable_name.group(1)
As I said, I am not a professional programmer but do use Python a lot at work and use a hell of a LOT of regex.
I know it’s bad practice to reuse variable names in this manner but I am frequently looking for 30 or more different things using regex so I always reuse my variables in this scenario so as not to waste 30 variables or more just to check if they are None. (DISCLAIMER: I work alone and am self-employed so nobody else is affected. All of my code is ultrasimple and is 80% throwaway).
If I could use this “self-assignment” operator my code would be considerably shorter. Plus, if we have +=, *=, etc. why not have them all together at the simple cost of shifting the equals sign?