Lists And Extra Commas at end

Chris Angelico rosuav at gmail.com
Tue Dec 24 18:58:22 EST 2019


On Wed, Dec 25, 2019 at 10:50 AM Avi Gross via Python-list
<python-list at python.org> wrote:
>
> 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.

IOW you recreate the same feature by having a meaningless line at the
end.  Unideal but sometimes necessary.

> 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 ...

People can learn. It's an extremely common idiom. If it's laid out
vertically, include the trailing comma. It's not exactly hard to
figure out.

ChrisA


More information about the Python-list mailing list