Can someone please point out what the point of assigning the result(s) of a plot to a dummy variable _ is like so:
_ = plt.plot(x_vers, y_vers, marker = '.', linestyle = 'none')
Usually I see code like this:
plt.plot(x_vers, y_vers, marker = '.', linestyle = 'none')
Is it better practice to use the dummy _ even if it is never used? if so, why?
plt.plot
returns an matplotlib.AxesSubplot
object or an array of them, depending on what you're plotting. If you're running that command in an interactive environment, and don't want its output dumped to output when run, you can either assign to a dummy variable or suppress with a semi-colon, but the latter isn't really pythonic.
If you're running a script, it makes no difference, because nothing is printed to stdout unless explicitly print
ed.
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