1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How to create kwargs from tuple?

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

  1. Stack

    Stack Membro Participativo

    I have a function with lots of optional arguments. I want to apply it to an enumeration of tuples, that'd specify only the non-default values for each parameter. Something like:

    def myf(foo = 11, bar = 17):
    print(foo + bar)

    for tup in [(foo = 1), (bar = 2)]:
    myf(*tup)


    The above should print 18 and 13, but I cannot figure out the syntax -- is this even possible?

    Continue reading...

Compartilhe esta Página