The benefits of trailing commas PREMIUM

Trey Hunner smiling in a t-shirt against a yellow wall
Trey Hunner
5 min. read 3 min. video Python 3.8—3.12

Let's talk about trailing commas in Python.

What's a trailing comma?

When I'm make a multi-line list, dictionary, tuple or function call (see wrap a long line in Python), I prefer to put the closing bracket or brace on its own line:

...

A Python Tip Every Week

Need to fill-in gaps in your Python skills? I send weekly emails designed to do just that.