Trailing comma

Michael Geary Mike at DeleteThis.Geary.com
Wed Oct 22 15:30:04 EDT 2003


> > Timo Virkkala wrote:
> > Maybe I should get into the habit of always including the
> > trailing comma and see where I get. Before this I didn't
> > even know that it was allowed.

> Georgy Pruss wrote:
> Another "solution" is just to look at the previous line and
> check if it has the comma or not. You'd better get a habit to
> THINK and not do things mechanically, as others suggest.

It is better to think and not do things mechanically, and that's exactly why
people add the trailing comma.

If you do things mechanically, you may leave out the trailing comma, because
it certainly isn't necessary.

If you think about making your code maintainable, you will look for ways to
prevent mistakes when people edit your code later. The trailing comma helps
prevent mistakes, so you'll use it.

-Mike






More information about the Python-list mailing list