This is the best explanation of this that I have found. A lot of times when people make things really simple, they neglect actually explaining something and expect you to understand something just from seeing it. Thanks for making this helpful video!
Best explanation ever, you didn't need to mention unnecessary terminology (which often makes you feel more confused) to perfectly explain the topic. Congrats! and thanks for the help!
I LOVE YOU MAN! I have been trying to understand this for so long now without any success. Finally I found you video and understood instantly. Thank you
Oh wow! thank you so much. Your videos are so clear on python basics and OOP. I am going through all your videos now. Self kept tripping me up unfortunately... until now! I never got a clear answer as to why we have two parameters in the method.
OOP can be quite confusing. It took me over 20 years before I understood its true purpose. That said, 'self' is just a mechanism in Python. You can ignore it and focus on the main topics of OO, like polymorphism and inheritance.
Thanks, I would like to do a video on GUI frameworks but it has to wait as I am working on a Neural-Network-from-scratch course. And it is more work than I expected.
Thanks. Each month, I give away 10 of my OO for Python courses on Udemy. Here is a free link you (or anyone else who reads this) can use. www.udemy.com/course/learn-object-oriented-programming-with-python/?couponCode=RUclips
I think the whole confusion with understanding the role of "self" comes from an ill chosen word "self". Since the word "self" in Python is an arbitrary string and not a reserved word (could be anythinh, check for yourselves with a snippet of code :), for educational purposes I am replacing "self" by "object" or "instance" and such code becomes instantly self explanatory (at least for me). In the example provided "e" is a name of an instance.
In this example, I create a class with initializer and raise_salary method where self is "shared" within the class. ruclips.net/video/_KvOcz1WUhk/видео.html
Great video now i understand what self is after yrs of search. However, when do you not use self? I am not an expert in python so please forgive my ignorance
Thanks for explanation But in Python Class fields and properties definition it's not clear like in C# and Java. self.salary is look like local variable, but in Python is used like public global variable.
Yes there are examples of class methods that do not use self. Class methods get cls (the class object) as first parameter and static methods get no additional first parameter at all.
@@python-for-everyone thx. Just read about self and cls. Followup question: Is it right that neither of them are keywords in python? „They are just ideal naming conventions whose name can be changed and yet the functionality would be the same“
It is a bit different. def set_salary is a function in the class that becomes a bound method when it is retrieved via attribute set_salary. If you want to dive in a bit deeper, watch this next: ruclips.net/video/x4j6bzbbx2o/видео.html
so are you saying that you could change it for anything like def __init__(whywouldanyonecreatingalangugemakeitsocrypticandconfusing,arg): whywouldanyonecreatingalangugemakeitsocrypticandconfusing.a = arg ??????
clicked because the thumbnail seems like dostoievsky
Haha, you are right. It does!
This was the most dummy proof explanation ever, after 8 youtube videos. This was the one with the eureka moment!!! Thanks Soooooo Much
That is a great compliment. Thanks!
Literally the same feeling after 8 videos again!
same brooo, ngl i am still a bit confused but i understand it 10 times more than i did 2 min ago
Happy for you because this video only made things more confusing
This is the best explanation of this that I have found. A lot of times when people make things really simple, they neglect actually explaining something and expect you to understand something just from seeing it. Thanks for making this helpful video!
Best explanation ever, you didn't need to mention unnecessary terminology (which often makes you feel more confused) to perfectly explain the topic. Congrats! and thanks for the help!
That is a really nice compliment! Thank you!
I LOVE YOU MAN! I have been trying to understand this for so long now without any success. Finally I found you video and understood instantly. Thank you
I started getting the concept before this video but to me this was very well and simply explained, congrats !
I watched a video 10-20 minutes long and did not understand anything. Here in 2 minutes I understood everything. Brilliant, thank you!
Thank you. Best 2 minute explanation ever.
Finally an explanation I understand. Thank you!
Oh wow! thank you so much. Your videos are so clear on python basics and OOP. I am going through all your videos now. Self kept tripping me up unfortunately... until now! I never got a clear answer as to why we have two parameters in the method.
What a great compliment! Have fun!
Appreciate that you repeat yourself. Im sure it was the difference between understanding and not understanding for many.
Thanks for that feedback. That is good to know!
Shortest and best explanation ever!!! Thank you bro!
You are welcome!
After a year i have found the right answer.. bro I really love you... Keep it up.
Man, This is so clearly explained. Unreal!
Thanks for the compliment!
Well this is explained in a very concise way, deserves a like and subscribe, thanks!
Thank you so much for the kind words!
Just subscribed to this channel so far the explanations are awesome please keep up the good work regards from Chile !
the perfect time you made a video for me thanks a lot.
This is a beautifully simple and intuitive explanation - great video! Subbed!
Thanks for the kind words!
Holy fuck! Finally a video that explains self properly and in a couple of minutes! Love how you walked through the execution! Thank you!
You are welcome. Glad it helped you.
Explanation helps a lot, and was easier to understand for me than other videos. Thank you
Thank you. That is a great compliment!
Best explanation ever!
Thank you!
Master, legend... you brought light to my dumb brain. Thank you so much!
what a legend, best explanation ever! Thanks
Wow, thanks!
finally I understood after lot of videos!!! that really make sense now!
Thanks for the compliment!
Thank you so much it helps me a lot. It so clearly. I try to find many places to get it. but only you vid helps me
Happy to help
Even with this simple explanation, OOP is still confusing...
OOP can be quite confusing. It took me over 20 years before I understood its true purpose. That said, 'self' is just a mechanism in Python. You can ignore it and focus on the main topics of OO, like polymorphism and inheritance.
The best explanation ever
finally someone is explaining it finally!
Thank you for keeping it simple and short.
well done! Looked for an answer all over google but this straight forward tutorial is the best explanations I found! 😄
very simple and easy to understand, thanks for the video
nice bro....perfect...just perfect...this channel will go far
That is so kind of you to say. Thanks!
glorious explanation. thank you so much!
that was fantascticly useful. Thanks mate
you are really great, thanks for the explanation :)
Clear and Crisp explanation, probably the best one..!!
If I can please request the content creator to do a video on Kivy ( self, root , app)
Thanks, I would like to do a video on GUI frameworks but it has to wait as I am working on a Neural-Network-from-scratch course. And it is more work than I expected.
Finally found the video where self is explained properly
Very helpful, thanks.
Glad it was helpful!
Thanks for this!
Very nice explanation, thank you ..
Thanks for the compliment!
really appreciate this explanation😀
Super clear explanation and simple yet straightforward illustrations. You deserve a like!
Thank you very much!
Great video..please continue to do more object oriented programming in python...
Thanks. Each month, I give away 10 of my OO for Python courses on Udemy. Here is a free link you (or anyone else who reads this) can use. www.udemy.com/course/learn-object-oriented-programming-with-python/?couponCode=RUclips
thank you very much. awesome explanation.
I think the whole confusion with understanding the role of "self" comes from an ill chosen word "self". Since the word "self" in Python is an arbitrary string and not a reserved word (could be anythinh, check for yourselves with a snippet of code :), for educational purposes I am replacing "self" by "object" or "instance" and such code becomes instantly self explanatory (at least for me).
In the example provided "e" is a name of an instance.
very clear. Thank You
Thanks a lot for this explanation
Thanks and once again big thanks! Like
You're the best.
thanks man, really helpful
Glad it helped!
Thanks for this
Any time
Really good explanation!!!
great video! thx
eureka! thank you!
thank you so much for work
You're welcome!
Thanks man!!!
Thank you so much.
May you be blessed by all of the different gods 😇 Life saver!
Thank you very much for that nice wish!
I finally understand.
Can you please show using self across other methods within or outside the classes?
In this example, I create a class with initializer and raise_salary method where self is "shared" within the class. ruclips.net/video/_KvOcz1WUhk/видео.html
Thank you so much that was really a great explanation ever
JESUS, ISSO ESTÁ TÃO BEM EXPLICADO QUE MESMO EU NÃO FALANDO INGLÊS EU ENTENDI 100%. DEUS TE ABENÇOE!!!!!!
Muito obrigado!
Took me two watches but it’s clicked, thanks!
Good to hear!
Great video now i understand what self is after yrs of search. However, when do you not use self? I am not an expert in python so please forgive my ignorance
To see when to use self and when not, watch this video next: ruclips.net/video/qX5TpBzpIwo/видео.html
Thanks bro
thanks a lot dope explanation
Thank you!
Very nice explanation. I subscribed to your RUclips channel
Thanks!
ooooooo that what it is, thank you
Thumbnail was the reason I clicked this video because I had the same feeling for self as the person in thumbnail had😂
I think we've all been there :-). Was the video helpful?
I think if you translate this video into many languages, it will be useful to many people
How do i print the name of the object when it is created - i.e how to print(e)...coz print(self) gives a location not 'e'
The object has no name. But if you mean a name attribute, then add this method to the class:
def __str__(self):
return self.name
I understand what its doing but why does it work?? Also, I feel like self = e but nobody says it.
Thanks for explanation
But in Python Class fields and properties definition it's not clear like in C# and Java.
self.salary is look like local variable, but in Python is used like public global variable.
I agree that C# makes it more clear. However, self.salary is an attribute, not a global variable.
That was great ! i feel really bad when i noticed likes ...
Thank you for the compliment!
Stupid question: Is „self“ always used when working with classes or are there examples where „self“ is better not be used (and why)?
Yes there are examples of class methods that do not use self. Class methods get cls (the class object) as first parameter and static methods get no additional first parameter at all.
@@python-for-everyone thx. Just read about self and cls. Followup question: Is it right that neither of them are keywords in python? „They are just ideal naming conventions whose name can be changed and yet the functionality would be the same“
@@luudest Your assumption is true. cls and self are conventions. I show this in a follow up video: ruclips.net/video/qX5TpBzpIwo/видео.html
why calling the instance wont make it explicit that you are calling int?
That is the way Python implemented the mechanism.
decent, but gets quite lost after 1:20
nice
What is caller at 1:55
The thing/user/code that calls the function.
Why isn't self implied then? what would happen if you didn't have self?
def set_salary isn;t attribute but method ?? and self.salary is attribute ? confusing ...
It is a bit different. def set_salary is a function in the class that becomes a bound method when it is retrieved via attribute set_salary. If you want to dive in a bit deeper, watch this next: ruclips.net/video/x4j6bzbbx2o/видео.html
thx
Why self. Salary =num
Mine goes salary.num()
TypeError: please consult with HR about your instance…
Then y we will be nt using this in jaba
No, Jaba does it implicitly
I still don't get it...at all
My guy dumbed down the explanation yet i still don't understand, you gotta super duper dumb down this stuff before i start understanding it
You sir, are A MAY ZING.
If someone would sit there and draw arrows around while explaining a code, I’d be a programmer in 2 min WTF
wish you had subtitle
you are god.
Take a deep dive into self in Python by learning bound methods: ruclips.net/video/x4j6bzbbx2o/видео.html
Bruhh it was that simple, BRUHHHHHHHHHHHHHHHHHH!
Once you see it, you go Bruhh :-)
I still don't get it :^)
but thanks
It took me a while to get it either. Here is an updated video that might help you further: ruclips.net/video/x4j6bzbbx2o/видео.html
Sappu
YES, I watched like 5 other videos on this and long ones but it just didn't click the e refers to the self!!!
E
Poor language design? Other languages don't need such nonsense.
I agree. In C#, "self" is not required, and functions do the same thing.
makes no sense
Hate python. Have 7 years of exp in Java
Coming from C# myself, I can imagine Python being strange at first. But if I can help you, just let me know.
we don't need to type "self" we can name it anything but the common is "self"
we could do this
def __init__(this,arg):
this.a = arg
so are you saying that you could change it for anything like
def __init__(whywouldanyonecreatingalangugemakeitsocrypticandconfusing,arg):
whywouldanyonecreatingalangugemakeitsocrypticandconfusing.a = arg
??????