Closures in Python | Explained with animations

preview_player
Показать описание
In this Python programming tutorial, we will learn how closures work in Python. We will also see how shared extended scopes and multi-scoped variables are implemented in Python using intermediary cell objects. Understanding closures helps us in understanding other language features like function decorators.

References
------------------

Recommended prerequisite
--------------------------------------------

Chapters
---------------
0:00 Prerequisites
0:12 First example code
0:51 Visual representation of first example
2:23 Closure
3:12 second example
4:26 Multiple closure instances
4:51 Comparing with classes
5:25 Shared free variables
5:54 Cell objects
7:01 attributes of function objects
Рекомендации по теме
Комментарии
Автор

These videos are AMAZING. I have watched a lot of python content but IMO this is honestly the best. Not brushing over anything - very technical and the animations are top notch. Fantastic work and thank you so much. You should put up a donate link!

doresearchstopwhining
Автор

biggest thanks bro when it comes to this matters. I spent almost 2 days learning this problem via your video. you r the best <3

thaibui
Автор

After listening to your video at 0.75 times and doing back and forth multiple times I finally understood the closure completely.
Thanks for the video.👍👍

bhushandhuri
Автор

This is high-quality material!!! Keep up the good work! I hope this channel will grow more and can help others.

hilmandayo
Автор

A weird question pops into my mind, what percentage of Python programmers really know this level of in-depth knowledge in the real world?

faramarztayyari
Автор

I like your way of teaching with visuals. Really helpful!!

priyankagupta
Автор

a very good video. I would request you to make a whole python playlist for intermediate to advanced level. You have a very unique way to explaining that make it easy to comprehend.

hasinabrar
Автор

great explanation good animations, keep on!

tomerlevi
Автор

awesome explanation❤‍🔥 thanks a ton for creating such quality content in best way to make difficult topics easy to understand with deepest explanation 💯

krushna
Автор

Great video, deep info. I had to watch at 0.75 speed cuz so deep.

johnaweiss
Автор

awsme!! hope u are doing more such videos ..

skirfan
Автор

awesome explanation, really helpful. I look forward upcoming video!!!

toan
Автор

would love to connect and see more videos !

sauravtarun
Автор

This is an amazing video!! Excellent explanation and animations!! I have subscirbed to you!! By the way, which software do you use for these animations?

dr.strangelove
Автор

good video, the animations are helpful

Tobi_Jones
Автор

This is great, bro. I've followed your channel.

LamNguyen-nmfq
Автор

Amazing.. Sreekant, can you please tune voice over a little bit? I am using 0.75 but still sometimes few words are very fast. And more videos please :). Keep up the good work.

catchalok
Автор

Nice video! Although a little bit too fast. Thanks!

MagnusAnand
Автор

5:08 to me, an object is a thing that has methods, like
counter.increment()
To me, it's counter-intuitive to say
my_inc.increment()

johnaweiss
Автор

You can do this:

def counter(num):
def increment(inc=1):
nonlocal num
num += inc
return num
return increment

counter10 = counter(10)
closureList = [counter10(3) for a in range(0, 5)]
print(closureList)


to output this:
[13, 16, 19, 22, 25]

However, if you don't return num in the inner function, the output (and the list) will be:
[None, None, None, None, None]
because the inner func is returning nothing, i.e, is returning "None" in each iteration

charprototypia
visit shbcf.ru