Lists And Extra Commas at end

Marco Sulla mail.python.org at marco.sulla.e4ward.com
Tue Dec 24 19:20:25 EST 2019


On Wed, 25 Dec 2019 at 00:56, Avi Gross
<avigross at verizon.net.via.e4ward.com> wrote:
> I may not be understanding what you are objecting to

I, sir, am objecting that I replied to a topic, and you answered to
me, but in another topic. You could have respond to me in the correct
topic, and then  create this other one (that I'm not really
interested).

Anyway.

About the extra comma, it's da**ed useful:

a = (
    42,
    1981,
    8,
    19,
    23,
)

If I have to comment out the last line, I can, **without having to
remove the comma before**. And if I have to add another number at the
end, I have not to remember to add the comma before.

########

The real problem is this one:

a = 1,

Unreadable and prone to subtle errors, because maybe you added the
comma by mistake. Caution: Debugging Nightmares.
The solution, IMHO?

DeprecationWarning, use (1, )

Explicit is better blablabla.


More information about the Python-list mailing list