Decorators in Python | Python Tutorial - Day #59

Поділитися
Вставка
  • Опубліковано 9 січ 2025

КОМЕНТАРІ • 344

  • @embarrassed_dodo
    @embarrassed_dodo Рік тому +39

    Harry bhai you are truly right when I started learn c in 2017 there were only a handful of channels with classroom type teaching videos, I joined a local coaching just to learn that language, still makes me think how quickly things have changed, all thanks to creators like you, and the god who created this tech called internet

    • @Anushreee1660
      @Anushreee1660 Рік тому +1

      thank cern

    • @Tristaxx
      @Tristaxx 11 місяців тому

      potti

    • @WinzzPlayzz
      @WinzzPlayzz 6 місяців тому +1

      Salute for that guy who created internet 🫡
      Mujhse mt puchna Google krlo 😅

  • @musicaljoker1115
    @musicaljoker1115 Рік тому +43

    To understand this you must know ( if you are a beginner like me)
    1)nested functions
    2)passing function as a parameter and argument
    3)returning function from function

  • @codewithjaffar
    @codewithjaffar Рік тому +144

    We need Django full course with amazing projects. Man 💣

  • @CoderInRain
    @CoderInRain Рік тому +14

    10:00 Harry bhai giving full motivation wala speech

  • @mohammadhasnat9065
    @mohammadhasnat9065 Рік тому +22

    # Define a decorator function
    def my_decorator(func):
    def wrapper():
    print("Something is happening before the function is called.")
    func()
    print("Something is happening after the function is called.")
    return wrapper
    # Use the decorator with the "@" symbol
    @my_decorator
    def say_hello():
    print("Hello!")
    # Call the decorated function
    say_hello()

    • @ajayshankar3200
      @ajayshankar3200 10 місяців тому +3

      Ye to chat gpt ka response hai😂

    • @muhammadnomanaslam184
      @muhammadnomanaslam184 7 місяців тому

      @@ajayshankar3200 😂😂 ho sakhta hai q k aksr comment chatgpt k hi hote hai aysay "# Use the decorator with the "@" symbol" yeh line dekh kr pata chal raha hai chatgpt nay kiya hai but literally jab takh kudh say mehnat kr k loogh nahi padenghay to apnay fool banatay rahenghay, please kudh say mehnat kiya kro, dusro ko apna code show off kr k apnay aapko fake happiness de kr kiya faida

  • @arnavkohli
    @arnavkohli Рік тому +51

    After about 60 days of this series, I believe that this series is really helpful for beginners but belive that there could be some higher topics too like best sorting methods, numpy, pandas etc (Hope it comes in the future)
    Overall i give it a 5 rating as Harry Bhai is really the GOAT ⭐️⭐️⭐️⭐️⭐️
    Keep up the good work 👏

    • @shivansuxinonmedical7800
      @shivansuxinonmedical7800 Рік тому +2

      tujhe kuch samaj bhi aaya hai kya

    • @datadecides
      @datadecides Рік тому +2

      He is making general python tutorial, what you are asking is related to data Science 🧪

    • @mayurkanth6987
      @mayurkanth6987 Рік тому +1

      He has made separate videos on Numpy, Pandas

  • @muhammadsaadaziz4485
    @muhammadsaadaziz4485 Рік тому +5

    This is the implementation of decorator pattern of Gang of Four, in which we add additional responsibility, if we use @ method then it apply on every call but second method only call on those on which we applied

  • @aniruddhwarkar8063
    @aniruddhwarkar8063 День тому

    we can use lambda function in place of def to write addition function . for example. def greet(fx):
    def mfx(*args,**kwargs):
    print("Good Morning")
    fx(*args,**kwargs)
    print("Thanks for using the Decorators function")
    return mfx add = greet(lambda a,b: print(a+b))
    add(10,5)

  • @haripadajana6700
    @haripadajana6700 5 місяців тому

    Best tutorials and guidance, organized by topic, in short videos with full descriptions, are awesome.

  • @anotech4411
    @anotech4411 Рік тому +5

    The intro video gives us just that much goosebump hype such that we are going to prepare for a mission right now.....!💫💥💥💥💛💚

  • @kishorshitole6909
    @kishorshitole6909 Рік тому +1

    timestamp 2.44 Harry sir Apaki teaching bahut hi acchi hai, is decorator ka example to bahut hi achha hai.
    mere paas shabda nahi hai aapko thank you bolane ke liye. Thank you .............upto infinity.

  • @na_yab_03
    @na_yab_03 19 днів тому

    Motivation from Harry bhai start from 10:04 💃💃

  • @devarshisingh6886
    @devarshisingh6886 11 місяців тому

    Harry Bhai. Really nice explanation. Saying modified function instead of wrapper and writing greet(hello)() solves my doubt and clear my concept. Thanks man and best wishes.

  • @VoiceThatMatter
    @VoiceThatMatter Рік тому +14

    Harry Bhai todays's lecture is amazing.I have a doubt that " *args and **kwargs " course main sayad nahi hey ,main follow kar rahan hun course ko,agar ho sake toh next video main iske bare main thoda explain kardete toh bahat ache se samajh aajayega.
    Thank You !

    • @learnCodeWithAshish
      @learnCodeWithAshish Рік тому +1

      Bro *args hai sayad it generally use when we do not have any idea that how many arguments a function take so check the argument video jisme types of argument baataya hai

    • @Anonymous-j8n8c
      @Anonymous-j8n8c Рік тому

      Args kwargs nhi honge but * , ** ke bareme bataya hsi jo apko tuple aur dictionary as arguments lene me help karegi

  • @sudhansubalasahoo
    @sudhansubalasahoo Рік тому +13

    Present sir
    Can you please tell the use of *args and **kwargs in detail and give more use - cases.

    • @username_taken_se_pareshan_boi
      @username_taken_se_pareshan_boi Рік тому +6

      As far I think, sometimes we don't know how much arguments we want to give or the user may give. For eg. A function that add some numbers. You may think as a developer that the user will give 2 numbers to add or 3 numbers. But what if the user gives 10 numbers to add up them? You don't know na. So, you use "**arga"... And return all the sum of that numbers. Then it won't be a static function. It'll become a dynamical function.

    • @dhanushreddy7892
      @dhanushreddy7892 Рік тому +1

      @@username_taken_se_pareshan_boi good bro

  • @thealexkr2667
    @thealexkr2667 Рік тому +5

    Thanks for updating my knowledge sir ji 🙏

  • @kanakdwivedi3773
    @kanakdwivedi3773 Рік тому +9

    as far as i remember , you have not shared *args and **karg in previous videos

  • @shreybarot4956
    @shreybarot4956 Рік тому +3

    Love u bhai because of u I have learned a lot in python

  • @only_hidden-identity
    @only_hidden-identity Рік тому +3

    Bro
    Thanks to you
    For giving us precious computer knowledge in todays technology era

  • @vaibhavsoni4680
    @vaibhavsoni4680 Рік тому

    def dec(fn):
    def modify(first,second):
    if second>first:
    first,second=second,first
    fn(first,second)
    return modify
    @dec
    def swap(a,b):
    print(a/b)
    swap(8,24)
    # dec ek decorator function hai jo swap function ko as a argument leta hai ,modify funtion us function ko modify karta hai or modify function return ho jata hai jisse dec funtion chlta hai

  • @AakarshGoyal
    @AakarshGoyal Рік тому +5

    "I will see you next time" is an emote for real, same smile and gesture every time lol it's amazing.
    #HarryBhaiOP
    #100DaysOfCode

  • @veereshspatil7083
    @veereshspatil7083 10 місяців тому

    That smile while saying "let's get started"
    😇🤩

  • @Random_shorts0906
    @Random_shorts0906 Рік тому

    Thanks sir, 5 min me concept clear kr diya aapne!

  • @HarshitaSaini-q9t
    @HarshitaSaini-q9t Рік тому

    your notes are not ignored. they are very useful.

  • @entity5678
    @entity5678 Рік тому +1

    thank you harry..this was helpful

  • @aksharasharma1469
    @aksharasharma1469 Рік тому +1

    I think he is a genius and I am mad b'coz I'm finding best python video's and I didn't even play his videos....but now I'm the luckiest....❤❤❤ Thank you sir and srry i believed on stupid rummors 💐💐

  • @mantashasheikh431
    @mantashasheikh431 8 місяців тому

    What a deep line brother God bless you

  • @narullah69
    @narullah69 Рік тому +2

    10:26 motivation level 999999999%

  • @MaxGaming-ip4tc
    @MaxGaming-ip4tc 9 місяців тому

    I feel like hugging you for this course ngl.❤

  • @darkelytragaming341
    @darkelytragaming341 Рік тому +4

    I'm a Backlogger of 26 classes but still watching this coz of curiosity 🙂

  • @Yzshsjdje24
    @Yzshsjdje24 Рік тому

    bro I am gratefull to you . thanks providing these resources free.

  • @AZIZULHAQ-j8c
    @AZIZULHAQ-j8c 23 дні тому

    Good content Harry Brother

  • @harishdwivedi6970
    @harishdwivedi6970 Рік тому

    you thought of anything , harry bhai is already with playlist waiting for u to come and learn from him........💙

  • @hasantariq5431
    @hasantariq5431 Рік тому +3

    Sir, you are doing just a great things for us .we don't have words to thank you .thanks a lot Sir, hate off to you 🤩🤩🤩😍

  • @Rishisoni001
    @Rishisoni001 7 місяців тому

    thank you for teaching us decorators.

  • @knandinij
    @knandinij Рік тому +2

    Always inspired by u d way u teach.grt Harry👍

  • @zayanahmad5706
    @zayanahmad5706 Рік тому

    Congratulation ! haris bro on 3.7 million students

  • @a2kgammer327
    @a2kgammer327 Рік тому

    Thank you for your best explanation

  • @biswajeet9826
    @biswajeet9826 4 місяці тому

    Bahut acha kaam!

  • @abhaysagar9865
    @abhaysagar9865 Рік тому +2

    Herry bhai,
    I am waiting for Laravel beginner Tutorial playlist. I am seen other laravel playlist but videos not easy. I request you please make a laravel playlist easy and best for beginners..😊

  • @rahulgurgude
    @rahulgurgude Рік тому

    best explanation harry ,thanks

  • @utkarshjaryal6170
    @utkarshjaryal6170 Місяць тому

    5:45 bhai kya bataya ha ek bar me doubt khatam

  • @GauravSuman-w2c
    @GauravSuman-w2c Рік тому +2

    (*args) and (*kwargs )did not explained by you :- HARRY BHAI😻😻😻😻😻😻😻

  • @debashismitra4108
    @debashismitra4108 9 місяців тому

    Vote for a video n Why, How, when is Indentation used
    👇

  • @prashantpanchal1303
    @prashantpanchal1303 Рік тому

    That's the motivation bro , This is the only one life changing rule. 💸💸💸

  • @jyotsanaanand8538
    @jyotsanaanand8538 2 місяці тому

    How you indented the 3 lines just by selecting at 3:38, is it editing?

  • @Rishisoni001
    @Rishisoni001 7 місяців тому

    Thank you for this video.

  • @harik3shhh
    @harik3shhh Рік тому +3

    Harry Bhai 23/01/2023 se ye Python series start kiya
    Aur aaj 25/01 pura 58 videos dekha hu with notes and practice
    Literally Nasha hogaya hai🙌

  • @akshatdhiman8819
    @akshatdhiman8819 Рік тому

    Amazing man❤ thanks!!

  • @python12180
    @python12180 9 місяців тому

    lots of love from Nepal my brother

  • @md.abdullahalmamun960
    @md.abdullahalmamun960 Рік тому

    thanks harry bi i am bangladeshi
    i love your video and you

  • @sonamlama8585
    @sonamlama8585 Рік тому +1

    Great sir❤️

  • @thoughtfulsoul100
    @thoughtfulsoul100 Рік тому

    "Harry bhai you are really awesome"🤩❤️

  • @jane_rosso
    @jane_rosso 6 місяців тому

    thank you bhaiya finally samjh agya😭😭🐢🐢

  • @abhishekkalagurki959
    @abhishekkalagurki959 Рік тому

    concept was explained vey well

  • @victorb22622
    @victorb22622 8 місяців тому +1

    *arg or **kwarg को chatgpt मे डालो aachi तरह से समझाया hsi

  • @lakshsinghania
    @lakshsinghania Рік тому

    6:11 value added ✅🫡

  • @HuzaifaKhan-iy5qj
    @HuzaifaKhan-iy5qj 5 місяців тому

    # Decorator function
    def decorator(fun): #Accepting the transaction func
    def wrapper(): #wrapping up the transaction func before and after
    print("Transaction initiated:")
    fun() #control goes back to original transaction function
    print("Transection been successfully completed:")
    return wrapper # control goes to the transaction call
    @decorator #Control goes to decorator
    def transaction():
    print("Transection is under process:")
    #Control goes to the decorator
    transaction()

  • @vaibhavsharma7931
    @vaibhavsharma7931 Місяць тому

    ham log ko *args and **kwargs pass karne ki koi jarurat nhi iske jagah par ye bhi kiya jaa sakta h :
    def greet(fx):
    def mfx(a, b):
    print("it will give you average of two numbers")
    fx(a, b)
    print("thanks for using this function")
    return mfx
    def avg(a, b):
    print((a + b) / 2)
    greet(avg)(6, 7)

  • @fambudevipuniya4139
    @fambudevipuniya4139 Рік тому +1

    Harry bhaiya thank you

  • @simple3688
    @simple3688 Рік тому +1

    Present Sir 🤞

  • @WkPowerHack
    @WkPowerHack Рік тому

    really very usefull this cource bhai

  • @fatemamotiwala8554
    @fatemamotiwala8554 Рік тому +2

    #Doubt Why did we make an mfx function inside greet function. Is it required to make two functions in a decorator everytime

    • @MRNOBODY-lx8ez
      @MRNOBODY-lx8ez 8 днів тому

      because we can return a function from a function only when returning function is defined inside that outer function

  • @shaliniagarwal8393
    @shaliniagarwal8393 Рік тому +1

    Sir pls make a video on app development with latest technology...

  • @shivamchaudhary8592
    @shivamchaudhary8592 Рік тому +1

    #Day59 Present Sir

  • @RulesofNature_Maths
    @RulesofNature_Maths Рік тому

    Great..!!👌👌

  • @jatinbhatt2222
    @jatinbhatt2222 Рік тому +2

    Present Sir on Day-59 ✋

  • @hrishikeshpatil2603
    @hrishikeshpatil2603 Рік тому +3

    @CodeWithHarry bro you did'nt teach us about *args and **kwargs

  • @Haribansh-zt5qz
    @Haribansh-zt5qz Рік тому

    Thanks Harry Bhai😍

  • @sssaamm29988
    @sssaamm29988 Рік тому +3

    Hi Harry, is this 100 day course enough for preparing for pcap certification?

  • @gautamsolanki3644
    @gautamsolanki3644 2 місяці тому

    video start from 10:24🔥 😆

  • @aravbehl5166
    @aravbehl5166 Рік тому

    looked at it a few times, almost there,but still revise once more

  • @carprankbyta
    @carprankbyta Рік тому +1

    so what is the need of defining mfx function , why we can't directly use the print statement and sandwich the function which is given as an argument in greet function , can anyone clear my doubt ???

  • @thesagardahiwal
    @thesagardahiwal Рік тому +1

    Hello! @code_with_harry sir,
    Ham firse wahi kr rahe hai kee, har def ko @greet kro. ab 1000 def hai to unko 1000 @greet lagao, koi aisa tarika hai kya kee ek(1) @greet lagao aur sare def ko apne aap lag jaye

  • @breadbutter8257
    @breadbutter8257 2 місяці тому +1

    Simpler Example
    def decorator(func):
    def wrapper():
    print("Start")
    func()
    print("END")
    return wrapper
    @decorator
    def hello():
    print("OG")
    #function calling
    hello()

  • @rajnishkumar1357
    @rajnishkumar1357 Рік тому +1

    6:33 ye karke ye karke . ye karke dikhao ye ye ye karke dikhao😅. Rap chal rha

  • @moviescenter6214
    @moviescenter6214 4 місяці тому +2

    harry bhai ek help chahiye ye aaap notes likhe hona uska pdf upload karo bhai description mai plz bcz it helps for revision

    • @avi.zworld
      @avi.zworld 2 місяці тому

      bhai replet ka link dia h description mai vhan sb hai notes bhi hai

  • @mdminhazalam2298
    @mdminhazalam2298 Рік тому +1

    Harry bhai , I want to give you a suggestion please teach slowly with simple example!!! plz

  • @karangupta9478
    @karangupta9478 Рік тому +1

    The code written in the notes is returning both the decorator and result. What does this mean?

  • @vishwajeetsingh5301
    @vishwajeetsingh5301 Рік тому

    @harry bhai? where you taught *args and **kwargs in previous videos?

  • @yadhunandan5765
    @yadhunandan5765 4 місяці тому

    Harry bhai thank you i wasted so much money going to a institute

  • @vinaypritwani
    @vinaypritwani Рік тому

    you are great!!

  • @ivar-jm7vj
    @ivar-jm7vj 10 місяців тому

    8:29 add function without arguments kaise call ho rha hai. anyone can you please explain ?

  • @syedaanam9811
    @syedaanam9811 Рік тому

    Samajh gyii 😁

  • @ajaysahani591
    @ajaysahani591 Рік тому +1

    Technology Sakha channel got (1 million subscribers) in 5 days😲😲😲

  • @foodiepanda6281
    @foodiepanda6281 11 днів тому

    code ka kum aur life gyaan jyada batata hai harry bhai

  • @rajshekhar9652
    @rajshekhar9652 Рік тому

    harry bhai app na please motivation rhne hi doo hahaha, but pdate bdyo ho❤❤

  • @abhishekvashistha2398
    @abhishekvashistha2398 Рік тому +2

    mfx function call toh hua nahi.... toh run kaise hua harry bro?

  • @badalsahoo3902
    @badalsahoo3902 Рік тому

    Big fan harry bhai😇

  • @applegamingff4051
    @applegamingff4051 Рік тому

    thanks for motivation

  • @IN_kakashi_
    @IN_kakashi_ Рік тому +1

    its start getting complex

  • @anishkumarmishra9620
    @anishkumarmishra9620 Рік тому +1

    What if we have 3 args to pass to a function ??

  • @qzarmy7059
    @qzarmy7059 9 місяців тому

    Sir few days back I am unwell 🤕 so say for don't continue this course.
    But I ma well so I continue this course.😊
    I am present bhaiya ❤

  • @RapJunkie
    @RapJunkie Рік тому +1

    Why do we need to wrap greet function with mfx() ?

  • @rokckerzzzz6080
    @rokckerzzzz6080 Рік тому +1

    Python Decorator behaves like Javascript First class Function. Thanks

  • @sagnikghosh9574
    @sagnikghosh9574 Рік тому

    LIne no. 16 i.e. greet(hello)() print's the greet message Twice i.e
    Good Morning
    Good Morning
    Hello world
    Thanks for using this function
    Thanks for using this function
    greet(hello()) does the real job i.e.
    Good Morning
    Hello world
    Thanks for using this function
    Coudn't understand why , it should have been syntax error according to me

    • @Deep_Imaginations
      @Deep_Imaginations Рік тому

      It is happening because you might forgot to comment out one of these two. (1) @greet or (2) greet(hello)()
      Just remove one of them you'll get the correct result. 😇

  • @codevoyage4194
    @codevoyage4194 Рік тому

    ROFL "Nahi ho aise theek" :D ...Haha very well explained and superb MOM like comments :)

  • @NEERAJ-dw9bt
    @NEERAJ-dw9bt 9 місяців тому

    Present sir 🤚

  • @theroshantune
    @theroshantune Рік тому

    wooooooow
    wanted to see me after 42 days
    day 58 done

  • @Kalkiraaj
    @Kalkiraaj Рік тому

    Please provide a playlist on freelancing tutorial