[Python] Does underscore (_) have any special functionality in Python, or is it just a...

Discussão em 'Python' iniciado por Stack, Julho 29, 2025.

  1. Stack

    Stack Membro Participativo

    freq, bin, _ = plt.hist(income, bins = 10, range = (0, 15), rwidth = 0.95)


    I understand that _ is just a variable name like any other and that using _ for ignored values is merely a convention.

    However, my question is: does python internally treat _ differently from other variables? Or is this usage purely a tradition with no intrinsic effect on memory management or execution?

    For example, instead of using _, I could simply return the ignored value to a regular variable, and everything still OK.

    freq, bin, _ = plt.hist(income, bins = 10, range = (0, 15), rwidth = 0.95)


    I've searched for official documentation on this, but i haven't found anything that explicitly states whether has internal functionality beyond being a naming convention. An answer that cites any available documentation would be greatly appreciated.

    Continue reading...

Compartilhe esta Página