Python Lambda Functions??

  Рет қаралды 154,552

b001

b001

Жыл бұрын

⭐ Join my Patreon: / b001io
💬 Discord: / discord
🐦 Follow me on Twitter: / b001io
🔗 More links: linktr.ee/b001io
Background Music:
Gentle Lo-Fi Vlog Background Music | Cookies by Alex-Productions | onsound.eu/
Music promoted by www.free-stock-music.com
Creative Commons / Attribution 3.0 Unported License (CC BY 3.0)
creativecommons.org/licenses/...

Пікірлер: 104
@thefoolishgmodcube2644
@thefoolishgmodcube2644 Жыл бұрын
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.
@steveman1982
@steveman1982 Жыл бұрын
But then again, python isn't really the right tool, if you want speed.
@thefoolishgmodcube2644
@thefoolishgmodcube2644 Жыл бұрын
@@steveman1982 Yeah, more reason why you should opt for the fastest Python code, to make up for its slowness.
@Inf1e
@Inf1e Жыл бұрын
if you obsessed with performance you really shouldn't use Python in first place
@bamremix8235
@bamremix8235 7 ай бұрын
@@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
@ajflink
@ajflink 5 күн бұрын
​@@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.
@deanbond007
@deanbond007 Жыл бұрын
Thank you for all the videos you make they're really informative and make learning so much easier
@b001
@b001 Жыл бұрын
Wow, thank you so much! So generous of you! I'm glad you enjoy my content!
@WibleWobble
@WibleWobble Жыл бұрын
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 👍
@TheRealKitWalker
@TheRealKitWalker Жыл бұрын
I simply love the fact, that how concise this video is. Fantastic. I finally Understood the dreaded lambda function. 💪 Thanks so much dude.
@FetchTheCow
@FetchTheCow 5 ай бұрын
Thank you for the use case! I didn't get it after your lambda short, but now I do.
@abhinavjoe
@abhinavjoe 7 ай бұрын
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.
@qayyax
@qayyax 3 ай бұрын
Thank you so much for this video. You are blessed
@alberthernandez5578
@alberthernandez5578 5 ай бұрын
Well this was easy to follow, thank you for the videos bro, they really help out
@robbertvandermeijden
@robbertvandermeijden Ай бұрын
perfect video. Straight to the point and told me everything I needed to know. Thanks!
@EricWAtchesVideos
@EricWAtchesVideos 4 ай бұрын
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.
@tompov227
@tompov227 Жыл бұрын
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
@jackkraus6948
@jackkraus6948 4 ай бұрын
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
@handlemyece
@handlemyece 2 ай бұрын
Thank you for the video!
@marclaygeorges2786
@marclaygeorges2786 8 ай бұрын
Your Python videos are always clear and concise explanations with great examples. Thank you for making these videos!
@b001
@b001 8 ай бұрын
Wow! Thank you so much! I’m so glad you enjoy them!!
@mirlamontano6640
@mirlamontano6640 Жыл бұрын
thank you for this video! very informative, useful and clear!! subscribed 💖
@tanmaypatel4152
@tanmaypatel4152 Жыл бұрын
Great video as always! BTW, which font are you using? It is so elegant.
@sapogatowo
@sapogatowo Жыл бұрын
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!
@gaberg21
@gaberg21 Жыл бұрын
you explained it super well! will be sending this video to friends who dont get it
@williamomon3894
@williamomon3894 7 ай бұрын
Hey man lovely vid , one question what extension got your IDE to look like that
@ksspqf6016
@ksspqf6016 Жыл бұрын
That's all very nice but I'm too stupid to put that skill into practise
@MarleykHarbdul-xp9ez
@MarleykHarbdul-xp9ez 19 күн бұрын
That's your problem
@ksspqf6016
@ksspqf6016 19 күн бұрын
​@MarleykHarbdul-xp9ez I've rewatched it again and now I'm even more confused than i was a year ago
@inteligenciaartificiuau
@inteligenciaartificiuau 3 ай бұрын
Amazing! Thanks!
@learningforever957
@learningforever957 10 ай бұрын
Thank you so much, perfectly explained
@viktoreidrien7110
@viktoreidrien7110 Жыл бұрын
excellent explanation, thanks man
@DiegoGomez-en7pn
@DiegoGomez-en7pn 11 ай бұрын
What software do you use to record your videos and shorts?
@sews1523
@sews1523 3 ай бұрын
awesome vid actually, thanks
@avgvstvs96
@avgvstvs96 Жыл бұрын
dont stop Sir Bool, these videos breath life into my soul
@Sdksakdjas
@Sdksakdjas Ай бұрын
what vscode theme do u use i really like this one!
@yashwantdhole7645
@yashwantdhole7645 9 ай бұрын
My goodness. This is the best and concise explanation of dreaded lambda function
@radishark8449
@radishark8449 3 ай бұрын
Simple and useful tutorial❤
@sreejishnair5922
@sreejishnair5922 Жыл бұрын
Bro what keyboard do you use?
@itsm0saan
@itsm0saan Жыл бұрын
what is the font you are using.?
@amansjourneys2
@amansjourneys2 3 ай бұрын
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
@francoli2281
@francoli2281 Жыл бұрын
what colour theme are you using?
@CHUAN-CHI
@CHUAN-CHI 5 ай бұрын
Thank you
@BroSience.c
@BroSience.c Жыл бұрын
What vs code theme do you use?
@xeurek4
@xeurek4 4 ай бұрын
Nice explanation
@AHWAProductions
@AHWAProductions 10 ай бұрын
man you explain it so well 😭
@dipeshsamrawat7957
@dipeshsamrawat7957 Жыл бұрын
Excellent ❤
@neomimendoza8339
@neomimendoza8339 Жыл бұрын
Hello! Could you please share your programming environment color scheme and your font? They're so easy on the eyes!
@ahbpoo
@ahbpoo Жыл бұрын
I searched his previous comments, where someone asked this question, and they got the answer: SynthWave '84
@baliDOTid
@baliDOTid Жыл бұрын
what's your vs code theme?
@darss10
@darss10 Жыл бұрын
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!
@chrysos
@chrysos Жыл бұрын
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
@chrysos
@chrysos Жыл бұрын
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()
@chrysos
@chrysos Жыл бұрын
run this code, click the button, press Enter and look at the output
@chrysos
@chrysos Жыл бұрын
i am not a pro its just what i could understand myself
@darss10
@darss10 Жыл бұрын
@@chrysos WOW thanks! So, if I need to pass arguments into my button command, I use lambda, is that it?
@ahbpoo
@ahbpoo Жыл бұрын
What theme do you use?
@chaithanyav6646
@chaithanyav6646 21 күн бұрын
Brilliant
@NeverSaid-
@NeverSaid- Ай бұрын
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]
@FollowPathfinder
@FollowPathfinder Жыл бұрын
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?
@fabricehategekimana5350
@fabricehategekimana5350 9 ай бұрын
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
@Oliver-Zen
@Oliver-Zen 8 ай бұрын
thanks!
@fcesteghlal
@fcesteghlal 2 ай бұрын
why music in the background?
@ninavanleeuwen1183
@ninavanleeuwen1183 10 ай бұрын
thank you for the video, but the music is too loud for me!
@Fisal_Gamal_Elgendy_2002
@Fisal_Gamal_Elgendy_2002 11 ай бұрын
thanks
@FazliddinSaydullayevbek
@FazliddinSaydullayevbek 3 ай бұрын
Your python is looks really beautiful how can i download that
@jacksonmadison9994
@jacksonmadison9994 4 ай бұрын
Man, computer science is so difficult.
@karimjapparov5324
@karimjapparov5324 7 ай бұрын
thank you
@MusicEffekt
@MusicEffekt 7 ай бұрын
please make the font a bit larger. Thanks
@jirafey_
@jirafey_ Жыл бұрын
Did you ever make content online? You seem to be professional asf
@Adaephonable
@Adaephonable 8 ай бұрын
This video is inline content...
@hubertgrzymkiewicz8883
@hubertgrzymkiewicz8883 7 ай бұрын
awesome!!
@CAMPERRRR
@CAMPERRRR Ай бұрын
You need to keep making content
@jonathanvioleta3578
@jonathanvioleta3578 7 ай бұрын
From my understanding, its basically a inline function ?
@chrysos
@chrysos Жыл бұрын
why do u use brakets with ure return ?
@jojojux
@jojojux Жыл бұрын
That triggered me too.
@b001
@b001 Жыл бұрын
I saw that when editing the video. I'm not sure why I did that lol
@magic_cow
@magic_cow 8 ай бұрын
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)
@stephenburke7108
@stephenburke7108 3 ай бұрын
you can lose lines 1-7 and just replace line 10 with: cubed = list(map(lambda x: x**3, nums))
@dakookh
@dakookh 8 ай бұрын
Jeez… Still can’t get it😢
@epsi
@epsi Жыл бұрын
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.
@ajflink
@ajflink 5 күн бұрын
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.
@Liz4rdMan
@Liz4rdMan 5 ай бұрын
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.
@jaksiz
@jaksiz 3 ай бұрын
You're awesome
@user-yn1yo4eb6v
@user-yn1yo4eb6v 8 ай бұрын
Salute to you.
@barbellbilly
@barbellbilly Жыл бұрын
What vscode theme is this?
@cvntdav
@cvntdav Жыл бұрын
Synthwave '84
@barbellbilly
@barbellbilly Жыл бұрын
@@cvntdav Thank you so much!
@carlosmillananhel2878
@carlosmillananhel2878 Жыл бұрын
for js people, as much as i understood lambda is the same that (params)=>{...}
@seanshimon
@seanshimon 2 ай бұрын
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))
@JustineEllyn
@JustineEllyn 3 ай бұрын
... half-life.
@neonblowfish
@neonblowfish 7 күн бұрын
Great video, but annoying music
@tsunningwah3471
@tsunningwah3471 3 ай бұрын
zhina
@vladoxgz
@vladoxgz Жыл бұрын
cubed = [n**3 for n in nums]
@ego-lay_atman-bay
@ego-lay_atman-bay Жыл бұрын
What are lambda functions in python? Horse crap
@mirzaimadbaig
@mirzaimadbaig Жыл бұрын
nicely explained
@wispaz1
@wispaz1 8 ай бұрын
So, writing lambda functions are better than writing normal functions?
@Zaryan___Zaryan
@Zaryan___Zaryan 7 ай бұрын
(💲10.00) thnaks your video is so best😀😀
@Fisal_Gamal_Elgendy_2002
@Fisal_Gamal_Elgendy_2002 11 ай бұрын
thanks
Python: Lambda, Map, Filter, Reduce Functions
9:59
Oggi AI - Artificial Intelligence Today
Рет қаралды 376 М.
Como ela fez isso? 😲
00:12
Los Wagners
Рет қаралды 32 МЛН
Final increíble 😱
00:39
Juan De Dios Pantoja 2
Рет қаралды 15 МЛН
1🥺🎉 #thankyou
00:29
はじめしゃちょー(hajime)
Рет қаралды 78 МЛН
5 Really Cool Python Functions
19:58
Indently
Рет қаралды 36 М.
Python's Map Function Explained..
3:02
b001
Рет қаралды 121 М.
Python dataclasses will save you HOURS, also featuring attrs
8:50
*Args and **Kwargs in Python
3:49
b001
Рет қаралды 246 М.
What is Scope in Python??
10:25
b001
Рет қаралды 44 М.
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1 МЛН
Python Yield Keyword??
3:18
b001
Рет қаралды 122 М.
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,7 МЛН
wyłącznik
0:50
Panele Fotowoltaiczne
Рет қаралды 23 МЛН
Which Phone Unlock Code Will You Choose? 🤔️
0:14
Game9bit
Рет қаралды 13 МЛН
How charged your battery?
0:14
V.A. show / Магика
Рет қаралды 3,2 МЛН
Индуктивность и дроссель.
1:00
Hi Dev! – Электроника
Рет қаралды 1,6 МЛН
МОЖНО ЛИ заряжать AirPods в чехле 🧐😱🧐 #airpods #applewatch #dyson
0:22
Apple_calls РЕПЛИКА №1 В РФ
Рет қаралды 23 М.