I wonder what ,= or , = means in python?
Example from matplotlib:
plot1, = ax01.plot(t,yp1,'b-') 
                It's a form of tuple unpacking. With parentheses:
(plot1,) = ax01.plot(t,yp1,'b-')   ax01.plot() returns a tuple containing one element, and this element is assigned to plot1. Without that comma (and possibly the parentheses), plot1 would have been assigned the whole tuple. Observe the difference between a and b in the following example:
>>> def foo(): ...     return (1,) ...  >>> (a,) = foo() >>> b = foo() >>> a 1 >>> b (1,)   You can omit the parentheses both in (a,) and (1,), I left them for the sake of clarity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With