Do you want to learn python from me with a lot of interactive quizzes, and exercises? Here is my project-based python learning course: codebasics.io/courses/python-for-beginner-and-intermediate-learners
I finally understood after wandering here and there. Can you extend this to advance level like decorators inside a decorators? decorators for coroutines object? I would love to learn it from you. Thank you.
With all due respect,I want to thank you for let me compleating basics of Python.Now I am looking to dig deeper.I am looking forward to get used to of Data Engineering/Analytic,so could you refer me which series of your video is good to start(1,2 or 3 series in row one after one)please.Thank you
Thank you for the video! It has been really helpful. Just want to ask one question though. Why time_it method needs to have a nested method, wrapper? what time_it does is to have wrapper function and nothing more. Is there something I missed understanding?
I've never used decorator inside decorator in my life. It sounds like a trick question and shows interviewers don't know how to take interviews. They should ask questions on stuff that is useful in day to day life
Hi thanks a lot for your videos, i am new to this platform(python) , is this 25 sessions of course enough to learn python course completely ? please help me with your comments .
Sure Kishore. This is good enough. Also I have new upto date tutorials in Hindi with more better content and detailed exercises. Here is the link of you want to watch those instead: ruclips.net/p/PLPbgcxheSpE1DJKfdko58_AIZRIT0TjpO
Could you explain what is returned within the time_it function? So the "return result" and "return wrapper"? And is the "return result" within the time_it function redundant? Again thanks for these clear tutorials! I also really enjoyed your tutorials about multithreading and multiprocessing. Could you make one about events, or event loops. And could you explain what asynchronous programming is (or is this just a term for multithreading/multiprocessing)?
time_it returns a function (or a function pointer). return result is not redundant because it is part of the function that is wrapped. I have noted down your tutorials request Sonny for those topics, I am working on deep learning series so not sure when I will get a chance but yea they are in my todo list now :) Now on asynchronous programming, in the world of internet and browsers when you are loading web page you might be loading 5 different components on your web page and while one component is being loaded you don't want the other one to be blocked on first one. Hence using asynchronous programming you just leave the first component do its work and move on to working on second one. Asynchronous programming is a higher level concept and to achieve this paradigm at lower level it uses multiprocessing/multithreading.
Thank you so much for explaining , I tried the same example but its giving me below error , could you please assist what wrong with this. import time def time_it(func): def wrapper(*args,**kwargs): start=time.time() result=func(*args,**kwargs) end=time.time() print(func._name_ +" took " + str((end-start)*1000) + " mili sec.") return result return wrapper
@time_it def calc_square(numbers): result = [] for number in numbers: result.append(number*number) return result
@time_it def calc_cube(numbers): result = [] for number in numbers: result.append(number*number*number) return result
array = range(1,100000) out_sq=calc_square(array) out_cube=calc_cube(array) Error- --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in 25 26 array = range(1,100000) ---> 27 out_sq=calc_square(array) 28 out_cube=calc_cube(array) 29 in wrapper(*args, **kwargs) 6 result=func(*args,**kwargs) 7 end=time.time() ----> 8 print(func._name_ +" took " + str((end-start)*1000) + " mili sec.") 9 return result 10 return wrapper AttributeError: 'function' object has no attribute '_name_'
Do you want to learn python from me with a lot of interactive quizzes, and exercises? Here is my project-based python learning course: codebasics.io/courses/python-for-beginner-and-intermediate-learners
Learn data science with python and pandas: ruclips.net/video/CmorAWRsCAw/видео.html
brother, you are the best online teacher. Thank you very much
Glad you like the videos on this channel! 🙏
decorators demystified... explained in simple yet beautiful way.. thank you codebasics
My pleasure 😊
Simplest tutorials ever. Thanks Codebasics.
great video , very easy to understand , already i watched more than10 videos. this is the best for me to understand as a beginner ..thank you..
😊👍 thanks and wish you all the best
I finally understood after wandering here and there.
Can you extend this to advance level like decorators inside a decorators? decorators for coroutines object? I would love to learn it from you. Thank you.
Thanks a ton. Simple and lucid explanation.
loved this explanation on decorators. Great Video :)👍
With all due respect,I want to thank you for let me compleating basics of Python.Now I am looking to dig deeper.I am looking forward to get used to of Data Engineering/Analytic,so could you refer me which series of your video is good to start(1,2 or 3 series in row one after one)please.Thank you
You should first do pandas series and then machine learning. I have both of these series on my channel
great explaination
Wonderful explanation .
Hello Sir
Thanks a lot for your videos.
I have gone through all 25 tutorials of python. What should i read next to learn python ?
You can start with my pandas tutorials now if you are interested in data science.
Thanks!!! Very good, strait-forward tutorial
👍☺️
Thank you for the video! It has been really helpful. Just want to ask one question though. Why time_it method needs to have a nested method, wrapper? what time_it does is to have wrapper function and nothing more. Is there something I missed understanding?
we can't just call wrapper function directly? like @wrapper
" Can we use decorator inside decorator?" Use cases of it? -- This is my interview question.. please share your view sir on this question..
I've never used decorator inside decorator in my life. It sounds like a trick question and shows interviewers don't know how to take interviews. They should ask questions on stuff that is useful in day to day life
@@codebasics thank you so much for your fast response...
@@codebasics Genuinely very true. Interviewers here ask shit like "write progrum to make star patern plis". Standards.
@Codebasis, out of curiosity, could we replace *args and **kwargs by parameters?, if so, how could we do it?.
I had a doubt here wrapper function return result but to which function it's going to return. Can you please clear this doubt.
Hi thanks a lot for your videos, i am new to this platform(python) ,
is this 25 sessions of course enough to learn python course completely ?
please help me with your comments .
Sure Kishore. This is good enough. Also I have new upto date tutorials in Hindi with more better content and detailed exercises. Here is the link of you want to watch those instead: ruclips.net/p/PLPbgcxheSpE1DJKfdko58_AIZRIT0TjpO
@@codebasics Thanks a lot
Could you explain what is returned within the time_it function? So the "return result" and "return wrapper"? And is the "return result" within the time_it function redundant?
Again thanks for these clear tutorials! I also really enjoyed your tutorials about multithreading and multiprocessing. Could you make one about events, or event loops. And could you explain what asynchronous programming is (or is this just a term for multithreading/multiprocessing)?
time_it returns a function (or a function pointer). return result is not redundant because it is part of the function that is wrapped. I have noted down your tutorials request Sonny for those topics, I am working on deep learning series so not sure when I will get a chance but yea they are in my todo list now :)
Now on asynchronous programming, in the world of internet and browsers when you are loading web page you might be loading 5 different components on your web page and while one component is being loaded you don't want the other one to be blocked on first one. Hence using asynchronous programming you just leave the first component do its work and move on to working on second one. Asynchronous programming is a higher level concept and to achieve this paradigm at lower level it uses multiprocessing/multithreading.
@@codebasics thank you for your response. Wish you all the best!
When i am trying to execute a code it showing 0.0 mili second and i am giving range (1 -100).
Can we use any function with decorators?
why did you use *args and **kwargs in wrapper ?
What is the order of time_it in which it is executing??
Str((end - start) how is it even possible to write this bcs these two parameters with - in between is not defined
Thank you so much for explaining , I tried the same example but its giving me below error , could you please assist what wrong with this.
import time
def time_it(func):
def wrapper(*args,**kwargs):
start=time.time()
result=func(*args,**kwargs)
end=time.time()
print(func._name_ +" took " + str((end-start)*1000) + " mili sec.")
return result
return wrapper
@time_it
def calc_square(numbers):
result = []
for number in numbers:
result.append(number*number)
return result
@time_it
def calc_cube(numbers):
result = []
for number in numbers:
result.append(number*number*number)
return result
array = range(1,100000)
out_sq=calc_square(array)
out_cube=calc_cube(array)
Error-
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
25
26 array = range(1,100000)
---> 27 out_sq=calc_square(array)
28 out_cube=calc_cube(array)
29
in wrapper(*args, **kwargs)
6 result=func(*args,**kwargs)
7 end=time.time()
----> 8 print(func._name_ +" took " + str((end-start)*1000) + " mili sec.")
9 return result
10 return wrapper
AttributeError: 'function' object has no attribute '_name_'
the date is June 8, 2022. you need double underscores func.__name__
2 "__" leading and trailing instead of 1 sir
99 0p