<<@DivyYadav-hg2js says : so basically i understood closer function its a function that will work only if we execute the inner func using a variable or assigning a variable to the outer func to disclose the inner func message only when we execute it . am i right corey?>> <<@vishnupandey3390 says : # A closure closes over the free variable of the environment def fun1(num): def getit(): print(num) return getit closure = fun1(2) closure()>> <<@ForWork-mj9fv says : Thank you Corey>> <<@thapasujan07 says : Thank you, Sir.>> <<@mitrakaramloo943 says : def outer_func(): message = 'Hi' # The variable message is enclosed in inner_func def inner_func(): print(message) # inner_func uses the enclosed message variable return inner_func # outer_func returns the inner_func # Get the returned function from outer_func my_inner_func = outer_func() # Execute the inner function my_inner_func() # Output: Hi>> <<@soulimanemammar2909 says : I guess the implementation of functions in Python is very different from C/C++. Otherwise, when the outer_func finishes executing, its stack frame get destroyed and will have the inner_func referencing a freed memory location !! Which is an undefined behaviour in C/C++>> <<@timmyl9361 says : Thnx dude. This is all I needed to understand it>> <<@alejandronieto576 says : Great video. Thanks a lot from Argentina.>> <<@byte_easel says : Anyone else finally ready to watch the decorators video after going through the first class functions --> closures rabbithole lol?>> <<@byte_easel says : Anyone else finally ready to watch the decorators video after the first class function --> closures rabbithole? Lol>> <<@0xssff says : WOT>> <<@viddeshk8020 says : This make more sense now. But why they created closure at the first place?>> <<@stephenpaek9175 says : Excellent>> <<@홍성의-i2y says : 4:24 definition of closure 6:17: a fancier way to define closure>> <<@Owlzon says : 😵‍💫😵‍💫Why are these Python gurus bad at teaching!! They start with how to add 1+1, and 10 seconds later it is a demonstration of how to find the area of the sun and its implication to the universe !!!!!!!!!!!!!!!!!!!!!!!!>> <<@Josh-Parkhill says : def brain(STRETCH!){ def stretch(*paradigms) paradigms = applied; return brain; youtubeLearning = brain(Schaefer);>> <<@Josh-Parkhill says : A function inside of a function, that’s then used as a variable-function>> <<@ismaeldescoings says : Where is the data stored?? This looks like quantum physics but for computers. This is *_quamputing_*>> <<@objnex says : Obviously intended positively and think this to be true somehow AI's Closure - outer function (responses variable) Corey's Closure - inner function (here it is) :) Thank you!>> <<@ChiefGuest says : So now we have to watch "logging" in python? 🙄>> <<@Benjiizus says : dude this is actually crazy how easy it gets when you understand it Thank you.>> <<@nasenblick says : Thanks for another great video that explains the mechanics, not just syntax. What I would like to understand better: What are real world use cases in which to use closures. Or in other words: In my problem solving efforts before writing code, what are patterns that call for closures.>> <<@yashyadav5605 says : @06:15 How the heck you have copied and paste>> <<@doneaton5099 says : Your example doesn't work.>> <<@valeriikubrak302 says : print_h1('Test Headline!') = html_tag('h1') This works under Sublime ans doesn't under VS Code. I don't know why. The same Python version..>> <<@bErKcorner says : The way I prefer to remember this concept: The outer function "closes over" an inner function, therefore it's a closure. While doing so, it "injects" its local scope into the function being closed. So the function that is returned will be executed with the injected state every time it is called.>> <<@ratikantasamal3201 says : I have recommended your channel to a lot of my colleagues over the years>> <<@scuti7073 says : free variable is the variable that is not defined within the inner function but is defined in the enclosing function. It can still be accessed in the enclosed function. "A closure is an inner function that remembers and have memory of the variables from the local scope from which it was created created (this includes arguments passed to the parent function)- even after the outer function has finished executing"- 4:50 A closure closes over the free variables from their environment- defined outside of the function/>> <<@Trippykiyay says : You are the best, I have been following your channel for years, and I always come back to your videos.>> <<@gresh1134 says : Mind blown>> <<@neoruss3553 says : Are closures the same in low level languages like c++ or rust? I never heard somebody mentioning usage of closures or callbacks in those kind of languages. Like there is something akward about it.>> <<@samrat1527 says : So closures and first-class functions are basically the same thing right?>> <<@markcuello5 says : SECURITY>> <<@BusinessDevelopmentSolution says : I have no words to thank you because this was a very tricky concept that I was trying to learn for last 2 days in dart and your video make me able to understand what exactly closure does, thank you so much>> <<@kwiky5643 says : well explained and easy to understand for beginners>> <<@AndrewMakarskiy says : Wikipedia sucks, Coreyshaferpedia rocks>> <<@moneeshkumar1838 says : Great explainer>> <<@sriharivaila7276 says : Thanks was very very helpful.>> <<@scullyy says : So are methods that have a free variable synonymous with closures?>> <<@drygordspellweaver8761 says : Couldn't the wrapped functions be done just as easily by having additional parameters in a normal function? I think more complex examples would have been good to really see the utility of closure and decorated functions.>> <<@АлексейСоков-ь8и says : 2022>> <<@akira_asahi says : Thank you for the video. I am grateful for your time and contribution. Kind regards, Akira.>> <<@ghph8314 says : Great video :)>> <<@rabbanimunna6992 says : I like the way you explain complex topics in a easy way.>> <<@NeumsFor9 says : For all the SQL folks out there, it's like a child stored procedure that remembers its input and output and is ready to return that input and output to its parent at a moment's notice......without having to define output parameters in the child sproc.>> <<@jagmeetsond6075 says : Top Video,really focuses on understanding.>> <<@onzamono says : 4:21 Me: What kind of sorcery is this!?>> <<@Nobody-wm9eg says : when i executed hi_func = outer_func(“hi”) , i got result hi instead of address. What is going on?>> <<@EW-mb1ih says : I get how closures work but I don't see any real use of this concept... Maybe someone has one?>> <<@aparna1498 says : super cool video, finally understood closures :)>>
VideoPro
>>