⬇️ *LEARN ON THE BEST LEARNING PLATFORMS (LINKS BELOW)* 😉💪 ⬇️ ☕ *Buy me a coffee:* www.buymeacoffee.com/fabiomusanni ❤️ *Support me monthly:* www.patreon.com/FabioMusanni 😍 *One-off donation:* www.paypal.me/FabioMusanni/ *SKILLSHARE* _(Python, Web Dev, UI/UX Design, Music, Art, Animation and a lot more)_ 🔗 skillshare.eqcm.net/5gxzD2 (Affiliate) *DATACAMP* _(Python, ChatGPT, SQL, Power BI, and a lot more)_ 🔗 datacamp.pxf.io/vN1bDj (Affiliate) *COURSERA PYTHON* _(For beginners, Data Science, Data Analysis, AI, Cybersecurity and a lot more):_ 🔗 imp.i384100.net/k0Nk60 (Affiliate) *COURSERA WEB DEVELOPMENT* _(Full Stack, Front-End, Back-End, Web Design and a lot more):_ 🔗 imp.i384100.net/EKWxBW (Affiliate) Thank you for the support!❤ 🎥OOP & Classes Playlist: ruclips.net/p/PLs8qUrmRvaR2LSaVLSvAGykNexBLrRqNt 🎥All my videos about Python: ruclips.net/p/PLs8qUrmRvaR0IT4IwJl-LSweAdACW-yLK
Thank you for the comment! I put a lot of effort into making this playlist, so I really appreciate it! 🥹💪 If you want to support the channel just a little bit you can buy me a coffee or get the source code of my videos here: www.buymeacoffee.com/fabiomusanni Thank you again! 🤗
Hi. Thank you for that nice video. At 5:09 i dont get how and why printing "player1.introduction()" works as we dont really call the method. We are "printing" a print and a return statement i don't get how that can print our 2 lines. Thanks for clarifications :-)
Thank you for the comment! 😊 Notice that we are also printing on line 28, so when you call introduction, you print the first string, then you call the parent introduction, which returns the second string, and then you return that second string and you print it (line 28). Maybe if we break that down a little more it's easier to understand: def introduction(self): print('Player introduction') second_string = super().introduction() return second_string So on line 28 it's sort of like: print(second_string) Because that's the value returned by the introduction method. Hopefully that's clearer now 😊💪
why in the class player do you need __init__(self, name, age, city, level)shouldn't just be __init__(self,level) because you are bringing the parent class person with "super.(__init__(name,age,city)"?
Hello, in this case, if when creating an instance of the class Player, you want to be able to pass name, age, city and level (4 arguments), then you need to have all of them as parameters of the init method of the Player class, If you were to just write (self, level), then when creating the instance, you'd only be able to enter one argument: Player(45) And of course you wouldn't have the name, age and city to then use with super(). It doesn't matter if you are using super() inside the class, Python just sees that when you create an instance of Player, you can enter just 1 argument (level) and nothing else, if you try to enter also name, age and city, you would get an error because you are passing more arguments than expected. That's why you need to have all of them there, even if you are using super(). If this helped and my videos are helpful for you, consider supporting the channel with a little donation, I'd really appreciate it: www.buymeacoffee.com/fabiomusanni
That would work but you are hard-coding it. You wouldn't have problems if you use that in small programs, but there could be instances where it might cause problems, especially if your code needs to be used by someone else. If I were to choose between using super() or hard-coding the value of the parent, I'd always use super().
⬇️ *LEARN ON THE BEST LEARNING PLATFORMS (LINKS BELOW)* 😉💪 ⬇️
☕ *Buy me a coffee:* www.buymeacoffee.com/fabiomusanni
❤️ *Support me monthly:* www.patreon.com/FabioMusanni
😍 *One-off donation:* www.paypal.me/FabioMusanni/
*SKILLSHARE*
_(Python, Web Dev, UI/UX Design, Music, Art, Animation and a lot more)_
🔗 skillshare.eqcm.net/5gxzD2 (Affiliate)
*DATACAMP*
_(Python, ChatGPT, SQL, Power BI, and a lot more)_
🔗 datacamp.pxf.io/vN1bDj (Affiliate)
*COURSERA PYTHON*
_(For beginners, Data Science, Data Analysis, AI, Cybersecurity and a lot more):_
🔗 imp.i384100.net/k0Nk60 (Affiliate)
*COURSERA WEB DEVELOPMENT*
_(Full Stack, Front-End, Back-End, Web Design and a lot more):_
🔗 imp.i384100.net/EKWxBW (Affiliate)
Thank you for the support!❤
🎥OOP & Classes Playlist: ruclips.net/p/PLs8qUrmRvaR2LSaVLSvAGykNexBLrRqNt
🎥All my videos about Python: ruclips.net/p/PLs8qUrmRvaR0IT4IwJl-LSweAdACW-yLK
thank you for the video, super helpful and straight to the point
Thank you so much for taking the time to leave a comment! I'm glad it was helpful 🤩💪
You are the BEST in explaining OOP!! Great playlist 👍🏽
Thank you for the comment! I put a lot of effort into making this playlist, so I really appreciate it! 🥹💪
If you want to support the channel just a little bit you can buy me a coffee or get the source code of my videos here: www.buymeacoffee.com/fabiomusanni
Thank you again! 🤗
Great job Fabio 👍🏼
Thank you for the comment! 💪
Thank You!
Glad you liked the video! 💪😉
Thanks for the video!
Hi. Thank you for that nice video.
At 5:09 i dont get how and why printing "player1.introduction()" works as we dont really call the method. We are "printing" a print and a return statement i don't get how that can print our 2 lines.
Thanks for clarifications :-)
Thank you for the comment! 😊
Notice that we are also printing on line 28, so when you call introduction, you print the first string, then you call the parent introduction, which returns the second string, and then you return that second string and you print it (line 28).
Maybe if we break that down a little more it's easier to understand:
def introduction(self):
print('Player introduction')
second_string = super().introduction()
return second_string
So on line 28 it's sort of like:
print(second_string)
Because that's the value returned by the introduction method.
Hopefully that's clearer now 😊💪
why in the class player do you need __init__(self, name, age, city, level)shouldn't just be __init__(self,level) because you are bringing the parent class person with "super.(__init__(name,age,city)"?
Hello,
in this case, if when creating an instance of the class Player, you want to be able to pass name, age, city and level (4 arguments), then you need to have all of them as parameters of the init method of the Player class, If you were to just write (self, level), then when creating the instance, you'd only be able to enter one argument:
Player(45)
And of course you wouldn't have the name, age and city to then use with super().
It doesn't matter if you are using super() inside the class, Python just sees that when you create an instance of Player, you can enter just 1 argument (level) and nothing else, if you try to enter also name, age and city, you would get an error because you are passing more arguments than expected.
That's why you need to have all of them there, even if you are using super().
If this helped and my videos are helpful for you, consider supporting the channel with a little donation, I'd really appreciate it: www.buymeacoffee.com/fabiomusanni
I'll subscribe to your channel@@FabioMusanni
I can do "Person.__init__(name, age, city) instead of "super().__init__(name, age, city) correct?
That would work but you are hard-coding it. You wouldn't have problems if you use that in small programs, but there could be instances where it might cause problems, especially if your code needs to be used by someone else.
If I were to choose between using super() or hard-coding the value of the parent, I'd always use super().
Thanks
you jump very fast not good for new guys. Bad!