▲ | iainmerrick 3 days ago | |||||||||||||||||||||||||||||||||||||||||||
It works the way you want if you add a trailing comma:
You might complain that that seems a bit obscure, but it only took me 10 or 20 seconds to discover it after pasting the original code snippet into an editor.The trailing comma is an improvement as it makes the diff clearer on future edits. Edit to add: occurs to me that I oversimplified my position earlier and it probably looks like I'm trying to have it both ways. I do advocate aiming for clean and clear formatting; I'm just against doing this manually. You should instead use automation, and steer it lightly only when you have to. For example, I explicitly don't want people to manually "tab-align" columns in their code. It looks nice, sure, but it'll inevitably get messed up in future edits. Better to do something simpler and more robust. | ||||||||||||||||||||||||||||||||||||||||||||
▲ | maratc 3 days ago | parent [-] | |||||||||||||||||||||||||||||||||||||||||||
The trailing comma communicates an intent of possibly adding more things in the future. I actually use it quite a lot -- when I have that intent. In the above example, if I think I have listed all of the `important_numbers`, there is a certain point of not having the trailing comma there. Here's another terrible example from `black`: From this:
To this:
The trailing comma it added makes no sense whatsoever because I can not have an intent of adding more things -- I've already exhausted the parameters in the string!On the top of it, I don't quite get why I need to change the way I write in order to please the machine. Who should be serving whom? Edit: changed "print" to "my_print" to not have to argue about named parameters of print ("sep", "file" etc.). Edit 2: here's a variant that `black` has no issues with whatsoever. It does not suggest a trailing comma or any other change:
So an existence of a trailing comma is a product of string length? | ||||||||||||||||||||||||||||||||||||||||||||
|