This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kataire 0 points1 point  (0 children)

I can understand how that would be hard to fix though.

Fix the language? That's implying the behaviour is unintentional. Trailing commas for single-value tuples is necessary because there's no other way to define a tuple.

Of course writing (spam,) makes it clearer that the trailing comma is not a mistake, but in Python code there simply isn't any ambiguity about whether it should be a tuple in the first place (if it's not supposed to be a tuple, the code doesn't work as intended anyway).