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...
=========================================================== - Наука та технологія
# 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)
How to copy this code from comment
@@AbdulWahid-fi7vs 😂
@@AbdulWahid-fi7vs you cant copy from mobile
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!
there is no way u been coding for 30 years and didnt know duck typing, might be time to switch careers
@@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.
@@alee9399 lol. grow up. guessing when they were teaching classes on manners you ducked out of those.
Very well structured. Definition, explanation, counter example, and conclusion with definition. This helped a lot. Thank you
loved it. it's clear, it's fun, short and to the point!
Great example, and good didatics. Thank you for the video.
Cheers. Best vid on this subject on YT.
Great applause for awesome code and to outstanding coder.👍👍👍
These vids helped me a lot. thank you Bro! Keep it up..❤🍀
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
very fun and well explained
Love all your vids, the way you explained this topic was especially clear!
Excellent
I am so addicted to write code when watching your video…Thanks! 😉
Stupendous video.
We can see fewer and fewer comments on the later videos. Guess many people have dropped the course already, lol.
@@BroCodez But really appreciated it that your videos helped me a lot!
If you referring to the 12hr I think people just downloaded it off of YT
And now view on their pc
bro....simple explanation....no BS
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.
great teaching !! hands up!!
awesome video
Thank you Bro!
Great video
Great input, thank you ❤
thank you for the information! so usefull
thx 4 vid bro!
nice video
i like this channel
Thanks Bro!
well explained
Thank you!
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?
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
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
TY bro
Thanks!
Wow!
thanks!
Thank you.
Thanks
thanks bro
👍
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?
easly the best
😍
Hi Bro, why the "class Chicken" and "class Duck" does not follow with parentheses like "class Person()"?
I forgot the (), but they will still function as intended without them. I should have made sure they were consistent
@@BroCodez Understood, thanks for the response!
honestly best video on youtube ,
thanks
True…
Sir ..why we but round brackets after class Person??
The duck is liking
is the () after class Person required? in other videos they were not there...
No it's not required, I typed that in accidentally
@@BroCodez ohh, thanks for clarifying bro
lovre you
love u
drop a comment !!
well, is this good or bad?
Python best laung
very clear and i think i understand, but i don't want it too.
meow meow meow!!!
cudo :)
this guy is giving the same name every where and I am getting confused .
w
Still commenting!
Thank you Game Tout!
10x
Thanks
thanks bro
Thanks