[Python] What do *args and **kwargs mean? [duplicate]

Discussão em 'Python' iniciado por Stack, Outubro 1, 2024.

  1. Stack

    Stack Membro Participativo

    What exactly do *args and **kwargs mean?

    According to the Python documentation, from what it seems, it passes in a tuple of arguments.

    def foo(hello, *args):
    print(hello)

    for each in args:
    print(each)

    if __name__ == '__main__':
    foo("LOVE", ["lol", "lololol"])


    This prints out:

    LOVE
    ['lol', 'lololol']


    How do you effectively use them?

    Continue reading...

Compartilhe esta Página