The difference between the "return line" and the "return line"

In a recent question of mine , I am quoting some Jake Vanderplas code . You can find the following code:

from matplotlib import pyplot as plt
from matplotlib import animation

fig = plt.figure()

ax = plt.axes(xlim=(0, 2), ylim=(0, 100))

line, = plt.plot([], [])

def init():
    line.set_data([], [])
    return line,

def animate(i):
    line.set_data([0, 2], [0,i])
    return line,

anim = animation.FuncAnimation(fig, animate, init_func=init,
                               frames=100, interval=20, blit=True)

plt.show()

In function initor animatereturn "value" line,(with a comma).

Question: Is there a difference with a return value that would be line(without a comma)?

thank

+2
source share
1 answer

line,is a tuple with one object in it. line- this is just a line object.

In [80]: line = object()

In [81]: line,
Out[81]: (<object at 0x9ee7fa8>,)
+6
source

All Articles