Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

412
Visualizações
Python: What is the difference between `lambda` and `lambda_`?

I know the function of lambda: and lambda var: , but what does lambda_: means acutally?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

lambda_ is just a variable name, like any other. Like foo or x.

If you saw:

lambda_: Something

Then that is actually a variable annotation, for type hints, so the same as:

num: int
num = 0
over 4 years ago · Santiago Trujillo Relatório

0

lambda: means lambda method doesn't take any argument

#!/usr/bin/env python3.10

def caller(var):
    var()


caller(lambda : print("OP"))

lambda var: means method is taking var as argument

#!/usr/bin/env python3.10

def caller(var,arg):
    var(arg)


foo = lambda x: print(x)
caller(foo, "OP")

lambda _: here _ is an argument

#!/usr/bin/env python3.10

def caller(var,__):
    var(__)


foo = lambda _ : print(_)
caller(foo, "OP")

output for all above program is OP

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda