Still confused about "self" in Python? Then watch this!

Поделиться
HTML-код
  • Опубликовано: 7 ноя 2024

Комментарии • 153

  • @natan.mendes
    @natan.mendes 7 месяцев назад +14

    clicked because the thumbnail seems like dostoievsky

  • @EdwinCrown
    @EdwinCrown 3 года назад +162

    This was the most dummy proof explanation ever, after 8 youtube videos. This was the one with the eureka moment!!! Thanks Soooooo Much

    • @python-for-everyone
      @python-for-everyone  3 года назад +8

      That is a great compliment. Thanks!

    • @SriramTantri25
      @SriramTantri25 2 года назад +1

      Literally the same feeling after 8 videos again!

    • @seeum
      @seeum 2 года назад +1

      same brooo, ngl i am still a bit confused but i understand it 10 times more than i did 2 min ago

    • @uncannyvalley3190
      @uncannyvalley3190 Год назад

      Happy for you because this video only made things more confusing

  • @dasnilpferd115
    @dasnilpferd115 2 года назад +29

    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!

  • @davidsanchezsimon1386
    @davidsanchezsimon1386 3 года назад +18

    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!

  • @eliaskarlsson9463
    @eliaskarlsson9463 3 года назад +1

    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

  • @bastou_chl6066
    @bastou_chl6066 3 года назад +11

    I started getting the concept before this video but to me this was very well and simply explained, congrats !

  • @dimaconaffetto
    @dimaconaffetto Год назад +1

    I watched a video 10-20 minutes long and did not understand anything. Here in 2 minutes I understood everything. Brilliant, thank you!

  • @wesleypresleymusic4940
    @wesleypresleymusic4940 2 года назад +2

    Thank you. Best 2 minute explanation ever.

  • @swedenludvig
    @swedenludvig 2 года назад +2

    Finally an explanation I understand. Thank you!

  • @jorgesanabria6484
    @jorgesanabria6484 День назад

    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.

  • @kylerasinger5256
    @kylerasinger5256 2 года назад

    Appreciate that you repeat yourself. Im sure it was the difference between understanding and not understanding for many.

  • @haile3619
    @haile3619 11 месяцев назад

    Shortest and best explanation ever!!! Thank you bro!

  • @umaraliarshad7454
    @umaraliarshad7454 Год назад

    After a year i have found the right answer.. bro I really love you... Keep it up.

  • @pacificlite
    @pacificlite Год назад

    Man, This is so clearly explained. Unreal!

  • @emirzarahman516
    @emirzarahman516 3 года назад +6

    Well this is explained in a very concise way, deserves a like and subscribe, thanks!

  • @mauricioacuna3746
    @mauricioacuna3746 3 года назад +1

    Just subscribed to this channel so far the explanations are awesome please keep up the good work regards from Chile !

  • @ROHITKUMAR-mu7ik
    @ROHITKUMAR-mu7ik 3 года назад +2

    the perfect time you made a video for me thanks a lot.

  • @andrewvalenski921
    @andrewvalenski921 Год назад

    This is a beautifully simple and intuitive explanation - great video! Subbed!

  • @bryanurizar
    @bryanurizar 2 года назад

    Holy fuck! Finally a video that explains self properly and in a couple of minutes! Love how you walked through the execution! Thank you!

  • @danielj.7656
    @danielj.7656 3 года назад +1

    Explanation helps a lot, and was easier to understand for me than other videos. Thank you

  • @setripper
    @setripper 2 года назад +1

    Best explanation ever!

  • @osmarramoa434
    @osmarramoa434 8 месяцев назад

    Master, legend... you brought light to my dumb brain. Thank you so much!

  • @juancruz151
    @juancruz151 2 года назад

    what a legend, best explanation ever! Thanks

  • @pallavkan
    @pallavkan Год назад

    finally I understood after lot of videos!!! that really make sense now!

  • @GiangNguyenTruong-oh7qp
    @GiangNguyenTruong-oh7qp 11 месяцев назад

    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

  • @brandon9638
    @brandon9638 3 года назад +6

    Even with this simple explanation, OOP is still confusing...

    • @python-for-everyone
      @python-for-everyone  3 года назад +3

      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.

  • @Sufailps
    @Sufailps Год назад

    The best explanation ever

  • @kobruh9642
    @kobruh9642 2 года назад

    finally someone is explaining it finally!

  • @greenapetranslord4870
    @greenapetranslord4870 2 года назад

    Thank you for keeping it simple and short.

  • @cesco24tv17
    @cesco24tv17 2 года назад

    well done! Looked for an answer all over google but this straight forward tutorial is the best explanations I found! 😄

  • @amalkrishnas1696
    @amalkrishnas1696 Год назад

    very simple and easy to understand, thanks for the video

  • @himanshu4807
    @himanshu4807 2 года назад

    nice bro....perfect...just perfect...this channel will go far

  • @souravendra
    @souravendra 2 года назад

    glorious explanation. thank you so much!

  • @clemeverett4173
    @clemeverett4173 2 года назад

    that was fantascticly useful. Thanks mate

  • @danielduran5969
    @danielduran5969 2 года назад +1

    you are really great, thanks for the explanation :)

  • @HimanshuSingh-xk9od
    @HimanshuSingh-xk9od 3 года назад

    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)

    • @python-for-everyone
      @python-for-everyone  3 года назад

      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.

  • @VAIBHAVMALHOTRA19
    @VAIBHAVMALHOTRA19 6 месяцев назад

    Finally found the video where self is explained properly

  • @training7574
    @training7574 Год назад

    Very helpful, thanks.

  • @typethedeveloper
    @typethedeveloper 2 месяца назад

    Thanks for this!

  • @mohamedashrafnk
    @mohamedashrafnk 3 года назад +1

    Very nice explanation, thank you ..

  • @yunjiexiao-i1j
    @yunjiexiao-i1j Год назад

    really appreciate this explanation😀

  • @shawnkhoo1949
    @shawnkhoo1949 3 года назад +1

    Super clear explanation and simple yet straightforward illustrations. You deserve a like!

  • @JeganSriragavan28
    @JeganSriragavan28 3 года назад +1

    Great video..please continue to do more object oriented programming in python...

    • @python-for-everyone
      @python-for-everyone  3 года назад

      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

  • @samvid1992
    @samvid1992 3 года назад

    thank you very much. awesome explanation.

  • @mberger4224
    @mberger4224 Месяц назад

    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.

  • @Rudra-go6us
    @Rudra-go6us 3 года назад

    very clear. Thank You

  • @MiBaLinuxTech
    @MiBaLinuxTech Год назад

    Thanks a lot for this explanation

  • @Debelinka
    @Debelinka Год назад

    Thanks and once again big thanks! Like

  • @tj1486
    @tj1486 8 месяцев назад

    You're the best.

  • @dadecky5276
    @dadecky5276 2 года назад

    thanks man, really helpful

  • @Bubblecoffee
    @Bubblecoffee 2 года назад

    Thanks for this

  • @MemasMaklas
    @MemasMaklas 2 года назад

    Really good explanation!!!

  • @memereview8149
    @memereview8149 10 месяцев назад

    great video! thx

  • @martinlancaster5109
    @martinlancaster5109 2 года назад

    eureka! thank you!

  • @Rikki-xj7gv
    @Rikki-xj7gv 6 месяцев назад

    thank you so much for work

  • @mcaddit6802
    @mcaddit6802 11 месяцев назад

    Thanks man!!!

  • @sashwattanay
    @sashwattanay 2 года назад

    Thank you so much.

  • @msteele919
    @msteele919 2 года назад

    May you be blessed by all of the different gods 😇 Life saver!

  • @MrDaoJones
    @MrDaoJones Год назад

    I finally understand.

  • @Ness-d2c
    @Ness-d2c 3 дня назад

    Can you please show using self across other methods within or outside the classes?

    • @python-for-everyone
      @python-for-everyone  2 дня назад

      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

  • @haameemshimar8828
    @haameemshimar8828 Год назад

    Thank you so much that was really a great explanation ever

  • @matheussoares4281
    @matheussoares4281 3 года назад

    JESUS, ISSO ESTÁ TÃO BEM EXPLICADO QUE MESMO EU NÃO FALANDO INGLÊS EU ENTENDI 100%. DEUS TE ABENÇOE!!!!!!

  • @esoopthederp7672
    @esoopthederp7672 2 года назад

    Took me two watches but it’s clicked, thanks!

  • @J-K-AG
    @J-K-AG 4 месяца назад

    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

    • @python-for-everyone
      @python-for-everyone  4 месяца назад

      To see when to use self and when not, watch this video next: ruclips.net/video/qX5TpBzpIwo/видео.html

  • @rudravaramsharan5351
    @rudravaramsharan5351 Год назад

    Thanks bro

  • @abhishektyagi4428
    @abhishektyagi4428 3 года назад

    thanks a lot dope explanation

  • @Misc_useful
    @Misc_useful 3 года назад

    Very nice explanation. I subscribed to your RUclips channel

  • @tutoro5567
    @tutoro5567 Год назад

    ooooooo that what it is, thank you

  • @saniasiddiquieast
    @saniasiddiquieast 3 месяца назад

    Thumbnail was the reason I clicked this video because I had the same feeling for self as the person in thumbnail had😂

    • @python-for-everyone
      @python-for-everyone  3 месяца назад

      I think we've all been there :-). Was the video helpful?

  • @thereisnoname2052
    @thereisnoname2052 2 года назад

    I think if you translate this video into many languages, it will be useful to many people

  • @bubblebath2892
    @bubblebath2892 7 месяцев назад

    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'

    • @python-for-everyone
      @python-for-everyone  7 месяцев назад

      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

  • @adrianayon5513
    @adrianayon5513 2 года назад

    I understand what its doing but why does it work?? Also, I feel like self = e but nobody says it.

  • @bg6159
    @bg6159 Год назад

    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.

    • @python-for-everyone
      @python-for-everyone  Год назад +2

      I agree that C# makes it more clear. However, self.salary is an attribute, not a global variable.

  • @raghuraman8829
    @raghuraman8829 3 года назад

    That was great ! i feel really bad when i noticed likes ...

  • @luudest
    @luudest Год назад

    Stupid question: Is „self“ always used when working with classes or are there examples where „self“ is better not be used (and why)?

    • @python-for-everyone
      @python-for-everyone  Год назад +1

      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.

    • @luudest
      @luudest Год назад

      @@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“

    • @python-for-everyone
      @python-for-everyone  Год назад

      @@luudest Your assumption is true. cls and self are conventions. I show this in a follow up video: ruclips.net/video/qX5TpBzpIwo/видео.html

  • @olagarto1917
    @olagarto1917 7 месяцев назад

    why calling the instance wont make it explicit that you are calling int?

  • @bunny.bunbob
    @bunny.bunbob 2 года назад +1

    decent, but gets quite lost after 1:20

  • @zoshida
    @zoshida 2 года назад

    nice

  • @rockstarprashantpanth1545
    @rockstarprashantpanth1545 2 года назад

    What is caller at 1:55

  • @MCSGproject
    @MCSGproject 2 года назад

    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 ...

    • @python-for-everyone
      @python-for-everyone  Год назад

      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

  • @elektro8174
    @elektro8174 2 года назад

    thx

  • @116sharan.d.k6
    @116sharan.d.k6 2 года назад +1

    Why self. Salary =num

    • @frozeneye100
      @frozeneye100 3 месяца назад

      Mine goes salary.num()
      TypeError: please consult with HR about your instance…

  • @manickam7231
    @manickam7231 Год назад

    Then y we will be nt using this in jaba

  • @Lynn-ds2qj
    @Lynn-ds2qj 2 года назад +5

    I still don't get it...at all

  • @DigitalHandle
    @DigitalHandle 2 года назад +1

    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

  • @Pandabubble
    @Pandabubble Год назад

    You sir, are A MAY ZING.

  • @Arcann_bhp
    @Arcann_bhp Год назад

    If someone would sit there and draw arrows around while explaining a code, I’d be a programmer in 2 min WTF

  • @proproductreview6892
    @proproductreview6892 3 года назад

    wish you had subtitle

  • @serious6037
    @serious6037 3 года назад

    you are god.

  • @python-for-everyone
    @python-for-everyone  Год назад

    Take a deep dive into self in Python by learning bound methods: ruclips.net/video/x4j6bzbbx2o/видео.html

  • @surprisedpikachu4716
    @surprisedpikachu4716 2 года назад

    Bruhh it was that simple, BRUHHHHHHHHHHHHHHHHHH!

  • @walterstraub150
    @walterstraub150 11 месяцев назад

    I still don't get it :^)
    but thanks

    • @python-for-everyone
      @python-for-everyone  11 месяцев назад

      It took me a while to get it either. Here is an updated video that might help you further: ruclips.net/video/x4j6bzbbx2o/видео.html

  • @gokulvenkatesan5798
    @gokulvenkatesan5798 3 года назад

    Sappu

  • @rohanofelvenpower5566
    @rohanofelvenpower5566 2 года назад

    YES, I watched like 5 other videos on this and long ones but it just didn't click the e refers to the self!!!

  • @AceThePeasant
    @AceThePeasant Год назад

    E

  • @neuzen
    @neuzen 3 года назад +1

    Poor language design? Other languages don't need such nonsense.

    • @Lexyvil
      @Lexyvil 2 года назад

      I agree. In C#, "self" is not required, and functions do the same thing.

  • @heuristicalgorithm8465
    @heuristicalgorithm8465 2 года назад

    makes no sense

  • @vitalii200
    @vitalii200 Год назад

    Hate python. Have 7 years of exp in Java

    • @python-for-everyone
      @python-for-everyone  Год назад

      Coming from C# myself, I can imagine Python being strange at first. But if I can help you, just let me know.

  • @JasimGamer
    @JasimGamer 2 года назад

    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

    • @joeking5211
      @joeking5211 Год назад

      so are you saying that you could change it for anything like
      def __init__(whywouldanyonecreatingalangugemakeitsocrypticandconfusing,arg):
      whywouldanyonecreatingalangugemakeitsocrypticandconfusing.a = arg
      ??????