In animate_decay.py of matplotlib examples, return statement is used with a trailing comma as in:
return line,
and the function is a normal function and is not a generator function.
So, I have written two versions of the same function, one with a trailing comma and another without one:
def no_trailing_comma(x):
return x + [10]
def trailing_comma(x):
return x + [10],
data = [1, 2, 3]
print("With trailing comma", trailing_comma(data))
print("With no trailing comma", no_trailing_comma(data))
In either case, the output was the same:
With trailing comma [1, 2, 3, 10]
With no trailing comma [1, 2, 3, 10]
The language specification (Python 3.6) does not make any special mention on trailing commas in return statements. Am I missing something?