Cameron,

I am not at all against the feature. I like it as my programming style is
like you describe. One entry per line indented at the same level, in
multiple languages. I often do graphics where I generate an image then
fine-tune additional parameters to get the effect I want. Some functions
take literally hundreds of options to adjust anything from text labels to
line types to colors and the high/low values on axes and so on. In languages
like R, I tend to put in a final entry with no trailing comma that is
something harmless that can be left in position and the same for the first
entry. Then my adding/deleting/editing of fields happens in the middle where
I always have a terminal comma.

My point is the convenience comes with a price for people who make a mistake
and are not told perhaps the dangling comma was a placeholder for something
to add that they forgot or ...

Again, the convenience is in some sense removing a mathematical symmetry,
but so what?

-----Original Message-----
From: Cameron Simpson <c...@cskk.id.au> 
Sent: Tuesday, December 24, 2019 5:12 PM
To: Avi Gross <avigr...@verizon.net>
Cc: python-list@python.org
Subject: Re: Lists And Extra Commas at end

On 24Dec2019 16:48, Avi Gross <avigr...@verizon.net> wrote:
>Let me switch gears to the terminal comma situation. Unlike many 
>languages, Python decided a dangling comma is perfectly allowable in 
>many situations, perhaps all.
>
>>>> a=[1,2,3,]
>>>> a
>[1, 2, 3]
[...]
>And, of course, you can use the same dangling comma in making a tuple, 
>dictionary or set and who knows where else.
>So, is that a feature you want warnings about? After all, a dangling 
>comma may simply mean you left something out and meant to add later?

To my mind the killer argument for trailing commas is things like multiline
lists, dicts or parameters. Example:

  def function(
      arg1=None,
      arg2=FOO,
  ):

Imagine this for a comewhat extended set of parameters. Or similar for a big
list or dict (eg a "table" as part of a class definition).

By always including the trailing comma it is easier to insert or delete
lines, and it reduces diff noise if you're using revision control (no commas
flickering on and off in the diff output).

Cheers,
Cameron Simpson <c...@cskk.id.au>

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to