[Python] Meaning of comma during assignment of function return value

Discussão em 'Python' iniciado por Stack, Setembro 8, 2025.

  1. Stack

    Stack Membro Participativo

    I understood simple concepts about comma operator in Python. For instance,

    x0, sigma = 0, 0.1


    means x0 = 0 and sigma = 0.1. But I obtained some code that has a line that looks like the following,

    y, xe = np.histogram(np.random.normal(x0, sigma, 1000))


    where the output of y and xe are the following:

    y
    Out[10]: array([ 3, 17, 58, 136, 216, 258, 189, 87, 31, 5], dtype=int64)

    xe
    Out[11]:
    array([-0.33771565, -0.27400243, -0.21028922, -0.146576 , -0.08286279,
    -0.01914957, 0.04456364, 0.10827686, 0.17199007, 0.23570329,
    0.2994165 ])


    I am not sure how to read the y, xe expression. What could I look up to understand what it's saying?

    Continue reading...

Compartilhe esta Página