Another thing is that lambda functions are faster to create and call compared to regular functions, so if you're obsessed with performance and your function only has a return statement you might as well make it a lambda function.
@@Inf1ewell tbh most of the popular machine learning and deep learning modules are easily accessible through python. So saying performance should be ignored while using python is stupid
@@bamremix8235 Also, there are ways to make things faster and more efficient in Python if you know what you are doing. There are so many people that blame bad performance on Python yet have so much redundancy in their code that there is no surprise that things are bad performance wise or using a large amount of memory. The most infamous example that I can think of is ArcGIS Pro. If you know, you know. Also, since Python is not bound by strict typing, you can do crazy things not possible in most other languages.
What I first used lambda functions for was when I created minesweeper in tkinter. The button components took a function parameter to call when pressed. Since in Minesweeper pressing an empty cell (no adjacent bombs, i.e. no number) reveals the cells around it, I wrote a recursive function that when given a row and column number revealed the cell value in that spot and called the function for the cells around it if the cell was empty. I used lambda to iteratively create functions using that function while passing in a set row and column. TL:DR you can use lambda to create a version of a defined function with filled in parameters
My man not only explained me what lamda functions are, but also cleared my doubts about how the map() function works. Very informative and well put video. You're the best.
Thank you for the clear explanation!! I think that like so many of these language features, they solve a problem that doesn't exist. It's nice to have features, but I doubt that I will end up using this ever.
Thank’s for the explanation. Lambda functions with map make things look so much easier, I wonder why is this even considered as intermediate Python knowledge?
I think it's because this concept belong to functional programming and go a bit deeper than what people thougth (It come from the lambda calculus). Generally people start with an imperative programming style, go to an object oriented programming style and maybe go to functional programming
@@fabricehategekimana5350 huh ? im not even taking intermediate yet and lambda is being introduced rn. You're telling me it gets deeper than this? I'm fucked ..
Ow mannnn, your code-communication skills are truly amazing! One question, do you have in mind continuing the 'How 2 Python' series? If so, when are you dropping the next video? Hope you are having a great day uwu!
This looks like a security vulnerability waiting to happen. And this whole example can be reduced to 2 lines of code: Nums =[3,4,5,6,7] Cubed = [item**3 for item in Nums]
Great video! Very simple and clear explanation!! I am currently learning tkinter and I was told that you can use the lambda keyword when assigning a command to a button -> button_1 = tkinter.Button(command=lambda: button_click()). What's the difference between using lambda and just assigning the function without lambda -> button_1 = tkinter.Button(command=button_click)?? Thanks!
tkinter takes functions as arguments and calls them with their own arguments. For example if u use .bind("", func) on the main window ure function gets call on press of the Return key (Enter) with ure mouse possitions and more as argumets. this does not matter for ure button command, because it provides no arguments. U can use both of ure examples, but if u want to provide ure own arguments u need to use lambda
In a thing I’m working on, I used lambda functions and assigned them to a variable, because they allowed my to put some a if else statement onto 1 line instead of 5 lines, this was amazing since this allowed me to bring 15 lines of codes down to 3 lines of code UPDATE: I put the lambda functions into the things that were calling it, now I am saving 3 more lines of code. Yippie! Function format: (Line 1: defining function Line 2: if statement Line 3: run function Line 4: else statement Line 5: run diffrent function)
my_map = lambda my_func, my_iter: (my_func(x) for x in my_iter) cubed = list(my_map(lambda x: x**3, nums)) Generators are great, except when they're not.
Thank you for this! My follow up question would be wouldnt it be easier to create a for loop to cube "nums" and add it to a list called "cubed"?? I'm not seeing how using lambda was faster/easier here
lambda is like decorator. They are useful tools but you are not severely crippling yourself by not using them. Due to what I am coding for and how I write Python code, I have never saw any need or desire to use decorators. I do see personal usage for lambda, though.
So i used panda and its very slow with my code and large data and chatgpt gave me lambda function for some codes i want to understand the core concept behind it can you do a video on data analysis using lambda?
Another thing is that lambda functions are faster to create and call compared to regular functions, so if you're obsessed with performance and your function only has a return statement you might as well make it a lambda function.
But then again, python isn't really the right tool, if you want speed.
@@steveman1982 Yeah, more reason why you should opt for the fastest Python code, to make up for its slowness.
if you obsessed with performance you really shouldn't use Python in first place
@@Inf1ewell tbh most of the popular machine learning and deep learning modules are easily accessible through python. So saying performance should be ignored while using python is stupid
@@bamremix8235 Also, there are ways to make things faster and more efficient in Python if you know what you are doing. There are so many people that blame bad performance on Python yet have so much redundancy in their code that there is no surprise that things are bad performance wise or using a large amount of memory. The most infamous example that I can think of is ArcGIS Pro. If you know, you know. Also, since Python is not bound by strict typing, you can do crazy things not possible in most other languages.
Thank you for all the videos you make they're really informative and make learning so much easier
Wow, thank you so much! So generous of you! I'm glad you enjoy my content!
Being able to play the piano whilst programming is a skill.
Makes you think, what he is playing piano with!
Maybe a keyboard @@Samreyna1
What I first used lambda functions for was when I created minesweeper in tkinter. The button components took a function parameter to call when pressed. Since in Minesweeper pressing an empty cell (no adjacent bombs, i.e. no number) reveals the cells around it, I wrote a recursive function that when given a row and column number revealed the cell value in that spot and called the function for the cells around it if the cell was empty. I used lambda to iteratively create functions using that function while passing in a set row and column.
TL:DR you can use lambda to create a version of a defined function with filled in parameters
its like you can read my mind, every time during the video i had a question, a second later you answered it. Well deserved sub 👍
I simply love the fact, that how concise this video is. Fantastic. I finally Understood the dreaded lambda function. 💪 Thanks so much dude.
My man not only explained me what lamda functions are, but also cleared my doubts about how the map() function works. Very informative and well put video. You're the best.
Amazing explanation, straight to the point and covered what I needed. Thank you!
Your Python videos are always clear and concise explanations with great examples. Thank you for making these videos!
Wow! Thank you so much! I’m so glad you enjoy them!!
Thank you for the clear explanation!!
I think that like so many of these language features, they solve a problem that doesn't exist.
It's nice to have features, but I doubt that I will end up using this ever.
perfect video. Straight to the point and told me everything I needed to know. Thanks!
That's all very nice but I'm too stupid to put that skill into practise
That's your problem
@MarleykHarbdul-xp9ez I've rewatched it again and now I'm even more confused than i was a year ago
@@ksspqf6016 dedication
@ksspqf6016 you're probably over complicating it
@@MarleykHarbdul-xp9ez what is wrong with you
Thank you for the use case! I didn't get it after your lambda short, but now I do.
That higher order function is eye opening now i understand.
Thank you so much for this video.
You are blessed
The music was an awesome touch, thanks a bunch
Excellent, concise, aesthetic explanation. Liked & subbed.
Thank you for the video!
Well this was easy to follow, thank you for the videos bro, they really help out
Fantastically simple and quick!
Thank’s for the explanation. Lambda functions with map make things look so much easier, I wonder why is this even considered as intermediate Python knowledge?
I think it's because this concept belong to functional programming and go a bit deeper than what people thougth (It come from the lambda calculus). Generally people start with an imperative programming style, go to an object oriented programming style and maybe go to functional programming
@@fabricehategekimana5350 huh ? im not even taking intermediate yet and lambda is being introduced rn. You're telling me it gets deeper than this? I'm fucked ..
My goodness. This is the best and concise explanation of dreaded lambda function
Great video as always! BTW, which font are you using? It is so elegant.
Ow mannnn, your code-communication skills are truly amazing!
One question, do you have in mind continuing the 'How 2 Python' series? If so, when are you dropping the next video?
Hope you are having a great day uwu!
Man, computer science is so difficult.
literally taking programming rn and Idk wtf I'm doing lol
This looks like a security vulnerability waiting to happen.
And this whole example can be reduced to 2 lines of code:
Nums =[3,4,5,6,7]
Cubed = [item**3 for item in Nums]
love the concise explanation
thank you for the video, but the music is too loud for me!
you explained it super well! will be sending this video to friends who dont get it
dont stop Sir Bool, these videos breath life into my soul
Great video! Very simple and clear explanation!!
I am currently learning tkinter and I was told that you can use the lambda keyword when assigning a command to a button -> button_1 = tkinter.Button(command=lambda: button_click()).
What's the difference between using lambda and just assigning the function without lambda -> button_1 = tkinter.Button(command=button_click)??
Thanks!
tkinter takes functions as arguments and calls them with their own arguments. For example if u use .bind("", func) on the main window ure function gets call on press of the Return key (Enter) with ure mouse possitions and more as argumets. this does not matter for ure button command, because it provides no arguments. U can use both of ure examples, but if u want to provide ure own arguments u need to use lambda
from tkinter import Tk, Button
def func(*args):
print(args)
tk = Tk()
tk.geometry("300x200")
tk.bind("", func)
button = Button( command=func)
button.pack()
tk.mainloop()
run this code, click the button, press Enter and look at the output
i am not a pro its just what i could understand myself
@@chrysos WOW thanks! So, if I need to pass arguments into my button command, I use lambda, is that it?
Nice explanation
It is also usable when you only use a function once so you won't need to create a whole function for it and no one will use it.
lambda: HALF LIFE
Amazing! Thanks!
you can lose lines 1-7 and just replace line 10 with: cubed = list(map(lambda x: x**3, nums))
Hey man lovely vid , one question what extension got your IDE to look like that
thank you for this video! very informative, useful and clear!! subscribed 💖
Thank you so much
awesome vid actually, thanks
Did you ever make content online? You seem to be professional asf
This video is inline content...
thank you
man you explain it so well 😭
good explanation but the music is disturbing
In a thing I’m working on, I used lambda functions and assigned them to a variable, because they allowed my to put some a if else statement onto 1 line instead of 5 lines, this was amazing since this allowed me to bring 15 lines of codes down to 3 lines of code
UPDATE: I put the lambda functions into the things that were calling it, now I am saving 3 more lines of code. Yippie!
Function format:
(Line 1: defining function
Line 2: if statement
Line 3: run function
Line 4: else statement
Line 5: run diffrent function)
my_map = lambda my_func, my_iter: (my_func(x) for x in my_iter)
cubed = list(my_map(lambda x: x**3, nums))
Generators are great, except when they're not.
Thanks
Simple and useful tutorial❤
Thank you for this! My follow up question would be wouldnt it be easier to create a for loop to cube "nums" and add it to a list called "cubed"?? I'm not seeing how using lambda was faster/easier here
lambda vs not lambda:
def my_map(my_func, my_iter) -> list:
result = []
for item in my_iter:
new_item = my_func(item)
result.append(new_item)
return result
nums = [3, 4, 5, 6]
cube_using_lambda = my_map(lambda x: x**3, nums)
print(cube_using_lambda)
def my_func_cube(size: int) -> int:
return size**3
cube_func = my_func_cube
print(my_map(cube_func, nums))
Thank you so much, perfectly explained
what vscode theme do u use i really like this one!
Your videos are really informative! What font do you use in your code editor, I really like it and I currently just use the default in mine
love the profile pic lol
You need to keep making content
why do u use brakets with ure return ?
That triggered me too.
I saw that when editing the video. I'm not sure why I did that lol
excellent explanation, thanks man
lambda is like decorator. They are useful tools but you are not severely crippling yourself by not using them.
Due to what I am coding for and how I write Python code, I have never saw any need or desire to use decorators. I do see personal usage for lambda, though.
please make the font a bit larger. Thanks
Hello! Could you please share your programming environment color scheme and your font? They're so easy on the eyes!
I searched his previous comments, where someone asked this question, and they got the answer: SynthWave '84
Thank you
for js people, as much as i understood lambda is the same that (params)=>{...}
Excellent ❤
why music in the background?
What software do you use to record your videos and shorts?
what's your vs code theme?
Jeez… Still can’t get it😢
So it's like an arrow function in JavaScript?
Brilliant
what is the font you are using.?
thanks!
Amazing
So i used panda and its very slow with my code and large data and chatgpt gave me lambda function for some codes i want to understand the core concept behind it can you do a video on data analysis using lambda?
what colour theme are you using?
... half-life.
From my understanding, its basically a inline function ?
thank you
Your python is looks really beautiful how can i download that
thanks
Bro what keyboard do you use?
What theme do you use?
What vs code theme do you use?
awesome!!
You're awesome
What vscode theme is this?
Synthwave '84
@@sysy_ep Thank you so much!
Good video, but don't add background music.
Salute to you.
cubed = [n**3 for n in nums]
Great video, but annoying music
zhina
Stop the music
What are lambda functions in python? Horse crap
nicely explained
what theme do you use??
So, writing lambda functions are better than writing normal functions?
(💲10.00) thnaks your video is so best😀😀
thanks