l, = plt.plot(x, y)
has got me slighty confused because
l = plt.plot(x, y)
also works, without the trailing comma after the l
I was wondering if any Python coders might comment to the comma's
significance. I've scanned my four books on Python and can't find any
plt.plot() returns an iterable type, and l, = plt.plot(x,y) will store
the first result of the iterable return value into l.
It looks like it's returning a list that contains one value though,
because if the list contains more than one value then l, = ..... would fail
Not having the , works as well - l will then be a list with one value,
rather than the first value of the list.
f = list()
list1() returns a list with one entry, the integer 1:
you can store this list in a variable foo:
>> foo = list1()
Or you can store the first entry in the list in the variable foo by
using foo, notation
>> foo, = list1()
There probably is reasonable difference between the variable l
containing a list of whatever plot() returns, and between it having the
first value in the list that plot() returns, however in your code
snippet, l is not used again after being called, so in practice it
doesn't make any difference.