25. Decorators [Python 3 Programming Tutorials]

Поделиться
HTML-код
  • Опубликовано: 8 ноя 2024

Комментарии • 44

  • @codebasics
    @codebasics  2 года назад

    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

  • @codebasics
    @codebasics  5 лет назад +1

    Learn data science with python and pandas: ruclips.net/video/CmorAWRsCAw/видео.html

  • @vinayak254
    @vinayak254 2 года назад

    brother, you are the best online teacher. Thank you very much

    • @codebasics
      @codebasics  2 года назад

      Glad you like the videos on this channel! 🙏

  • @ramcharan8876
    @ramcharan8876 4 года назад

    decorators demystified... explained in simple yet beautiful way.. thank you codebasics

  • @Rafian1924
    @Rafian1924 2 года назад

    Simplest tutorials ever. Thanks Codebasics.

  • @ygcjayalal
    @ygcjayalal 3 года назад +1

    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..

    • @codebasics
      @codebasics  3 года назад +2

      😊👍 thanks and wish you all the best

  • @shaikhshafeen
    @shaikhshafeen Год назад

    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.

  • @7deepakpandit
    @7deepakpandit 4 года назад +2

    Thanks a ton. Simple and lucid explanation.

  • @harshvardhanpardeshi3584
    @harshvardhanpardeshi3584 8 месяцев назад

    loved this explanation on decorators. Great Video :)👍

  • @skkkks2321
    @skkkks2321 5 лет назад

    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

    • @codebasics
      @codebasics  5 лет назад

      You should first do pandas series and then machine learning. I have both of these series on my channel

  • @shivampradhan6101
    @shivampradhan6101 2 года назад

    great explaination

  • @ayeshamallika2417
    @ayeshamallika2417 2 года назад

    Wonderful explanation .

  • @gurpreettata
    @gurpreettata 5 лет назад +1

    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 ?

    • @codebasics
      @codebasics  5 лет назад +1

      You can start with my pandas tutorials now if you are interested in data science.

  • @MarcosScalabrin
    @MarcosScalabrin 3 года назад

    Thanks!!! Very good, strait-forward tutorial

  • @elliekongnamul
    @elliekongnamul 2 года назад +1

    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?

    • @elliekongnamul
      @elliekongnamul 2 года назад

      we can't just call wrapper function directly? like @wrapper

  • @pandaparas8500
    @pandaparas8500 5 лет назад

    " Can we use decorator inside decorator?" Use cases of it? -- This is my interview question.. please share your view sir on this question..

    • @codebasics
      @codebasics  5 лет назад +3

      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

    • @pandaparas8500
      @pandaparas8500 5 лет назад

      @@codebasics thank you so much for your fast response...

    • @CliffCarmichael
      @CliffCarmichael 4 года назад

      @@codebasics Genuinely very true. Interviewers here ask shit like "write progrum to make star patern plis". Standards.

  • @Nearco1000
    @Nearco1000 4 года назад +1

    @Codebasis, out of curiosity, could we replace *args and **kwargs by parameters?, if so, how could we do it?.

  • @chandutejareddy7764
    @chandutejareddy7764 2 года назад

    I had a doubt here wrapper function return result but to which function it's going to return. Can you please clear this doubt.

  • @dkishore599
    @dkishore599 5 лет назад

    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 .

    • @codebasics
      @codebasics  5 лет назад +1

      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

    • @dkishore599
      @dkishore599 5 лет назад

      @@codebasics Thanks a lot

  • @sonny8595
    @sonny8595 5 лет назад

    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)?

    • @codebasics
      @codebasics  5 лет назад +1

      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.

    • @sonny8595
      @sonny8595 5 лет назад

      @@codebasics thank you for your response. Wish you all the best!

  • @lokeshdagur7227
    @lokeshdagur7227 3 года назад +1

    When i am trying to execute a code it showing 0.0 mili second and i am giving range (1 -100).

  • @manojthakuria2742
    @manojthakuria2742 3 года назад

    Can we use any function with decorators?

  • @brightenglish08
    @brightenglish08 2 года назад

    why did you use *args and **kwargs in wrapper ?

  • @pankajchandel1000
    @pankajchandel1000 3 года назад

    What is the order of time_it in which it is executing??

  • @debojitmandal8670
    @debojitmandal8670 3 года назад

    Str((end - start) how is it even possible to write this bcs these two parameters with - in between is not defined

  • @shivgupta1363
    @shivgupta1363 3 года назад

    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_'

    • @javierv.5242
      @javierv.5242 2 года назад

      the date is June 8, 2022. you need double underscores func.__name__

    • @lambball4425
      @lambball4425 2 года назад

      2 "__" leading and trailing instead of 1 sir

  • @avinayrawat747
    @avinayrawat747 11 месяцев назад

    99 0p