As long as your function doesn't need a while loop inside, you can use a list comprehension to nest if/else blocks and for loops indefinitely. All you need to do is either unpack your list (eg x,y=myfunc(args)) or if you only return one output simply set the index to zero (eg [blah if blah == criteria for blah in iterable][0]). However, I wouldn't recommend it.
When I learn in c++ There is capture clause to select variables from the surrounding scope i.e maximum is the first layer outside of it's declaration.. And we can choose whether to take it by reference or by value.. On the other hand when I learn kotlin, We wanted to use lambda when we need to pass the last argument to a function.. Also in kotlin I think there are so many abusing lambda function that make us compulsory to use them because it is built into the languange
The recommendation in PEP-8 you are running into is: Always use a def statement instead of an assignment statement that binds a lambda expression directly to a name. Recommended: def f(x): return 2*x Not recommended: f = lambda x: 2*x I use vscode with auto pep8 . And whenever i save my program it'll convert lambda to a function. So is it not recommended to assign a variable to a lambda function?
Great video Tim. Yes Dheeraj, the appropriate use of lambda in a single variable environment per PEP 8: E731 states. powers = lambda x, y: x ** y is wrong though it will work. def powers(x, y): return x ** y would be correct. I would argue however, that a more verbose solution is always more useful where lambda is not required. New programmers will often try to fit as much code into one line as possible because they are told it's "cleaner and easier to read."
Dang, I've always seen lambda but never really understood what use it could have for my Python open world text adventure, now my eyes are open lol. Time to see if I can find better use cases for this in some of my calculations.
I have autism so I take everything literally and “anonymous function” is useless to me, so these examples are PERFECT for me to learn and comprehend wtf is going on
I've seen people calling normal functions through lambda functions in places were it's not possible to call the normal function directly. Why do people do that and why does lambda work in these sort of situations ?
as stated in the video, they're a cleaner way than defining a new function, why create an entirely new function to do something making a messier file when you can use a Lambda instead?
YO just wanna say to believe in Jesus for he loves u so much that that he died for u so u can have a relationship with him. Believe in him and ask him for forgiveness of your wrongdoings
perfect teaching method for foreigners. hugs from Brazil
You have much much better explanations than I found written.
Man dude you have a way with explaining material, so that everyone can understand.
Your videos are really clear and to the point! Thanks Tim!
Thanks for the explanation and example of lambda with the map function.
Thanks for the light bulb moment Tim! Cheers man. Love your videos, I'll spread the good word.
Thanks for that simple yet easy to digest explanations about lambda.
Very helpful tutorials. I like your teaching style. Thank you so much for taking the time to create them and for sharing.
This one was amazing!
You has come a long way dude!
Always had trouble understanding this when written, great video, very straightforward explanation
Wow.... best explanation for this function! Thanks so much!
So helpful...you won a subscription
Thank you helped so much
Very well explained. All clear to me now.
great tutorial 10/10. will definitely be binging these later
I've always struggled to explain this while mentoring other engineers. Nice video and great examples. I think I was overdoing it.
Top class video
thanks a lot , you are great in explaining about lambda
As long as your function doesn't need a while loop inside, you can use a list comprehension to nest if/else blocks and for loops indefinitely. All you need to do is either unpack your list (eg x,y=myfunc(args)) or if you only return one output simply set the index to zero (eg [blah if blah == criteria for blah in iterable][0]).
However, I wouldn't recommend it.
This is why I ask people not computers because the information may be the same but the way it’s delivered isn’t.
Thank you again Tim, Your videos are awesome
Greeeeat video! Well explained, and with great examples. Thank you!
love your videos , can you make a tutorial series on making pacman using pygame ??
MAAAAAAAAN, you're the best! just subscribed
AHHHHhhHH the white background!
What a great tutorial, thanks mate!
When I learn in c++
There is capture clause to select variables from the surrounding scope i.e maximum is the first layer outside of it's declaration..
And we can choose whether to take it by reference or by value..
On the other hand when I learn kotlin,
We wanted to use lambda when we need to pass the last argument to a function..
Also in kotlin I think there are so many abusing lambda function that make us compulsory to use them because it is built into the languange
Thank you Tim
Well that finished quick. Thanks
The recommendation in PEP-8 you are running into is:
Always use a def statement instead of an assignment statement that binds a lambda expression directly to a name.
Recommended:
def f(x): return 2*x
Not recommended:
f = lambda x: 2*x
I use vscode with auto pep8 . And whenever i save my program it'll convert lambda to a function.
So is it not recommended to assign a variable to a lambda function?
Great video Tim. Yes Dheeraj, the appropriate use of lambda in a single variable environment per PEP 8: E731 states.
powers = lambda x, y: x ** y is wrong though it will work.
def powers(x, y): return x ** y would be correct.
I would argue however, that a more verbose solution is always more useful where lambda is not required. New programmers will often try to fit as much code into one line as possible because they are told it's "cleaner and easier to read."
great. thanks Tim!
Better explanation
Really helpful video to understand Lambda functions quickly. However the mechanical keyboard loud noise is quite annoying.
You can see mine also. Very detailed Python tutorials in the playlist. One R tutorial too, by the way.
Nice explanation
so, lamda is just a 'one line function' and the only action it does, it returns you a value immidiately
Dang, I've always seen lambda but never really understood what use it could have for my Python open world text adventure, now my eyes are open lol. Time to see if I can find better use cases for this in some of my calculations.
I have autism so I take everything literally and “anonymous function” is useless to me, so these examples are PERFECT for me to learn and comprehend wtf is going on
My next months will totally be dedicated to Python given that there is such a comprehensive teacher like Tim out there. Thank you ☺
nice vid.
newList = list(filter(lambda x: x%2==0, a))
Thank you bro!
thank you!
Are python lambdas similar in C#?
Thanks
I've seen people calling normal functions through lambda functions in places were it's not possible to call the normal function directly. Why do people do that and why does lambda work in these sort of situations ?
so lambda functions are like arrow functions in javascript in their utility?
Also please tell about Tensorflow in Python and Pygame
I have many videos on my channel teaching pygame...
What about Tensorflow dear sir please tell Tensorflow
I'm still kinda confused why exactly anonymous functions are useful. When are they a better option than defining a function?
as stated in the video, they're a cleaner way than defining a new function, why create an entirely new function to do something making a messier file when you can use a Lambda instead?
Basically JS arrow functions right?
commonet
activate windows
Please tell about Pygame please i beg you
Corman Răzvan owowowowo
YO just wanna say to believe in Jesus for he loves u so much that that he died for u so u can have a relationship with him. Believe in him
and ask him for forgiveness of your wrongdoings