Python duck typing 🦆

Поділитися
Вставка
  • Опубліковано 3 січ 2021
  • Python duck typing tutorial example explained
    #python #duck #typing
    duck typing = concept where the class of an object is less important than the methods/attributes
    class type is not checked if minimum methods/attributes are present
    “If it walks like a duck, and it quacks like a duck, then it must be a duck.”
    class Duck:
    def walk(self):
    print("This duck is walking")
    def talk(self):
    print("This duck is qwuacking")
    class Chicken:
    def walk(self):
    print("This chicken is walking")
    def talk(self):
    print("This chicken is clucking")
    class Person():
    def catch(self, duck):
    duck.walk()
    duck.talk()
    print("You caught the critter!")
    duck = Duck()
    chicken = Chicken()
    person = Person()
    person.catch(chicken)
    Bro Code merch store 👟 :
    ===========================================================
    teespring.com/stores/bro-code-5
    ===========================================================
    music credits 🎼 :
    ===========================================================
    Up In My Jam (All Of A Sudden) by - Kubbi / kubbi
    Creative Commons - Attribution-ShareAlike 3.0 Unported- CC BY-SA 3.0
    Free Download / Stream: bit.ly/2JnDfCE
    Music promoted by Audio Library • Up In My Jam (All Of A...
    ===========================================================
  • Наука та технологія

КОМЕНТАРІ • 78

  • @BroCodez
    @BroCodez  3 роки тому +18

    # duck typing = concept where the class of an object is less important than the methods/attributes
    # class type is not checked if minimum methods/attributes are present
    # “If it walks like a duck, and it quacks like a duck, then it must be a duck.”
    class Duck:
    def walk(self):
    print("This duck is walking")
    def talk(self):
    print("This duck is qwuacking")
    class Chicken:
    def walk(self):
    print("This chicken is walking")
    def talk(self):
    print("This chicken is clucking")
    class Person():
    def catch(self, duck):
    duck.walk()
    duck.talk()
    print("You caught the critter!")
    duck = Duck()
    chicken = Chicken()
    person = Person()
    person.catch(chicken)

    • @AbdulWahid-fi7vs
      @AbdulWahid-fi7vs 3 роки тому +1

      How to copy this code from comment

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

      @@AbdulWahid-fi7vs 😂

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

      @@AbdulWahid-fi7vs you cant copy from mobile

  • @bobmathiasiii
    @bobmathiasiii 5 місяців тому +4

    I have been coding for over 3 decades and have never seen ANYONE explain coding as well as you. Even after all this time I continue to enjoy learning new approaches and you make it so easy! Thanks!

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

      there is no way u been coding for 30 years and didnt know duck typing, might be time to switch careers

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

      @@alee9399 dude, i was coding on an apple 2e before classes and duck coding was a thing. why are you calling me out when all i am doing is paying respect to well explained topic. the only classes you should thinking about are ones that teach maturity and manners.

    • @bobmathiasiii
      @bobmathiasiii Місяць тому +1

      @@alee9399 lol. grow up. guessing when they were teaching classes on manners you ducked out of those.

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

    Very well structured. Definition, explanation, counter example, and conclusion with definition. This helped a lot. Thank you

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

    loved it. it's clear, it's fun, short and to the point!

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

    Great example, and good didatics. Thank you for the video.

  • @paulcap9688
    @paulcap9688 2 роки тому +3

    Cheers. Best vid on this subject on YT.

  • @aadilkhan9725
    @aadilkhan9725 3 роки тому +6

    Great applause for awesome code and to outstanding coder.👍👍👍

  • @shavindasilva
    @shavindasilva 2 роки тому +1

    These vids helped me a lot. thank you Bro! Keep it up..❤🍀

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

    awesome, save a lot of my time, was reading 2 page explaination since 3 hrs and could not understand and this video cleared the concept in just 5 mins

  • @bjrn-magnekristensen2444
    @bjrn-magnekristensen2444 8 місяців тому +1

    very fun and well explained

  • @mikemartelles7688
    @mikemartelles7688 3 місяці тому

    Love all your vids, the way you explained this topic was especially clear!

  • @ganeshsannidhi815
    @ganeshsannidhi815 3 роки тому +3

    Excellent

  • @flammabletfm3405
    @flammabletfm3405 2 роки тому +1

    I am so addicted to write code when watching your video…Thanks! 😉

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

    Stupendous video.

  • @PoorKid1922
    @PoorKid1922 2 роки тому +7

    We can see fewer and fewer comments on the later videos. Guess many people have dropped the course already, lol.

    • @PoorKid1922
      @PoorKid1922 2 роки тому +3

      @@BroCodez But really appreciated it that your videos helped me a lot!

    • @sR-III
      @sR-III Рік тому

      If you referring to the 12hr I think people just downloaded it off of YT

    • @sR-III
      @sR-III Рік тому

      And now view on their pc

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

    bro....simple explanation....no BS

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

    Thank you brocode you explained the concept so beautifully that it is cemented in my brain and I will never forget the concept of Duck Typing.

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

    great teaching !! hands up!!

  • @s.d.2551
    @s.d.2551 Рік тому

    awesome video

  • @henriquefelinimena7433
    @henriquefelinimena7433 3 роки тому +2

    Thank you Bro!

  • @ahmetaydn4416
    @ahmetaydn4416 2 роки тому

    Great video

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

    Great input, thank you ❤

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

    thank you for the information! so usefull

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

    thx 4 vid bro!

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

    nice video

  • @NOTHING-en2ue
    @NOTHING-en2ue Рік тому

    i like this channel

  • @tarikyassa1076
    @tarikyassa1076 3 роки тому +1

    Thanks Bro!

  • @nefissakhedher1380
    @nefissakhedher1380 2 роки тому

    well explained

  • @SuperStarEevee
    @SuperStarEevee 2 роки тому

    Thank you!

  • @tara2337
    @tara2337 3 місяці тому

    you are great Bro! TBH, though your explanation about duck typing was concise and to the point, I still feel like I need more explanation for this topic, does anyone else feel the same?

  • @ThankYouESM
    @ThankYouESM 3 роки тому +1

    Subscribed and liked even though I already learned all that was shown for Python over a decade ago aside from the walrus feature. One of my goals is to build a... Python script to C++ code translator... that would at least be able to create 3D games

    • @BigBrother4Life
      @BigBrother4Life 3 роки тому +1

      That's big goal, I believe there should be universal coding translator; I'm tired of learning so many languages but i think its a very distant possibility

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

    TY bro

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

    Thanks!

  • @beingzero7541
    @beingzero7541 2 роки тому

    Wow!

  • @Nadssh
    @Nadssh 3 дні тому

    thanks!

  • @ahiamatagabriel5696
    @ahiamatagabriel5696 2 роки тому

    Thank you.

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

    Thanks

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

    thanks bro

  • @dantec.dagandanan3732
    @dantec.dagandanan3732 Рік тому

    👍

  • @sR-III
    @sR-III Рік тому

    I download the 12hr clip bro and it's phenomenal , I'm at 4hrs 30 now
    I do wonder though, will I be able to create an app that's simple as collect data and some functions of creating a graph?

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

    easly the best

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

    😍

  • @tianyaopu9593
    @tianyaopu9593 3 роки тому +3

    Hi Bro, why the "class Chicken" and "class Duck" does not follow with parentheses like "class Person()"?

    • @BroCodez
      @BroCodez  3 роки тому +6

      I forgot the (), but they will still function as intended without them. I should have made sure they were consistent

    • @tianyaopu9593
      @tianyaopu9593 3 роки тому +3

      @@BroCodez Understood, thanks for the response!

  • @cykachu9720
    @cykachu9720 2 роки тому +3

    honestly best video on youtube ,
    thanks

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

    Sir ..why we but round brackets after class Person??

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

    The duck is liking

  • @arkamukhopadhyay2177
    @arkamukhopadhyay2177 3 роки тому +3

    is the () after class Person required? in other videos they were not there...

    • @BroCodez
      @BroCodez  3 роки тому +3

      No it's not required, I typed that in accidentally

    • @arkamukhopadhyay2177
      @arkamukhopadhyay2177 3 роки тому +1

      @@BroCodez ohh, thanks for clarifying bro

  • @prasannamahendrachavhan3612

    lovre you

  • @HussainAli-sb1dv
    @HussainAli-sb1dv 9 місяців тому

    love u

  • @simonzzzaaa
    @simonzzzaaa 2 роки тому

    drop a comment !!

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

    well, is this good or bad?

  • @technoremo1625
    @technoremo1625 2 роки тому

    Python best laung

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

    very clear and i think i understand, but i don't want it too.

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

    meow meow meow!!!

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

    cudo :)

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

    this guy is giving the same name every where and I am getting confused .

  • @decooly
    @decooly 3 місяці тому

    w

  • @Amir_Plays_non_stop
    @Amir_Plays_non_stop 3 роки тому +1

    Still commenting!

    • @BroCodez
      @BroCodez  3 роки тому +2

      Thank you Game Tout!

  • @user-os5ky3zh8r
    @user-os5ky3zh8r 3 місяці тому

    10x

  • @rubenc4696
    @rubenc4696 3 місяці тому

    Thanks

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

    thanks bro

  • @xyz8206
    @xyz8206 3 роки тому

    Thanks