▲ | maratc 3 days ago | ||||||||||||||||||||||||||||||||||
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? | |||||||||||||||||||||||||||||||||||
▲ | lenzm 3 days ago | parent [-] | ||||||||||||||||||||||||||||||||||
Yes, it gets a trailing comma if it's on it's own line. That way when you add/remove arguments in a multi-line call it's only a one-line diff. This doesn't apply when the diff is only one line anyway. Who's to say you don't add a new argument to the function in the future, like
| |||||||||||||||||||||||||||||||||||
|