Python Lambda Expressions Tutorial: what, how, when and why

preview_player
Показать описание
Take a few minutes to learn about this important feature of the Python language.
Рекомендации по теме
Комментарии
Автор

These channel still has so much good things to teach
Why does the videos just stopped?

cristinocanga
Автор

Please don't die, your explanations are good :c

azulpurpura
Автор

"if" statement in lambda for fun:
test = lambda x: '>= 0' if x>=0 else '<0'
test(1), test(0), test(-1)


another example => lambda x: 'positive' if x>0 else 'negative' if x<0 else 'zero'

voytechj
Автор

you mention tkinter, so it is good to know how to make a functions factory with lambdas. In tkinter callbacks cant have arguments and it is hard to distinguish what button was pressed, lambda with catch value can help:

def button_callback(bt_id):
print(f'Button {bt_id}')

for i in range(10):
b = Button(text=f"Button{i}", command=lambda x=i: button_callback(x))
b.pack()

partial from functools can be used as well: b=Button(text=f"Button{i}", command=partial(button_callback, i))

voytechj
Автор

Hello Sir! 3 months and not a single new video? :( Are you done with your channel? We miss you man

Murciallog
Автор

I hope you're doing well, but I'm f... tired waiting of you :) Please come back... There are no quality tutorials on youtube ..

Murciallog
Автор

can we use a for loop in a lambda expression?
im getting error

subhashriroy
Автор

You coded "def: concatenater()" ... not "def:concatenater(x)"... yet the function knew to pass your provided argument to the lambda expression in the function, could you explain this? Obviously it worked, but shouldn't you need to label your function arguments when defining a function?

Sparham
Автор

Hi Live Python I need some help in python

nitishvio