Python Methods and self

Sdílet
Vložit
  • čas přidán 10. 03. 2016
  • This Video Tutorial looks at a Python method and how it is added to a class. It also considers the formal parameter self.

Komentáře • 108

  • @unkindled_dreg
    @unkindled_dreg Před 3 lety +16

    I have been learning to program for 2 years, and until this video I had only grasped 50% of what "self" actually meant. I deeply appreciate all the tutors I have been learning under, however, this video shows that abstract concepts can be taught with minimal complexity and teaching isn't a skill everyone truly posses. Thank you, John.

    • @johnphilipjones
      @johnphilipjones  Před 3 lety +5

      Thank you for taking the time to give such positive feedback.
      Best wishes
      Phil

  • @moonchildxmochixhobi
    @moonchildxmochixhobi Před 4 lety +11

    FINALLY!!!!! I actually finally understand what self even means. Printing the id of self just solidified my understanding. YOU. ARE. AN. AMAZING. TEACHER. I'm going to look through your videos from now on when I need to learn a concept. Simply amazing!

    • @johnphilipjones
      @johnphilipjones  Před 4 lety +2

      Thank you for your generous comment. Please check out the website where videos are are organised into sections.
      www.PythonByteSize.com
      Best wishes Phil

  • @Ralphfish4
    @Ralphfish4 Před 7 lety +54

    I feel obligated to comment on this video due to its quality. I wasn't able to understand "self" before watching this video and I've been programming in and learning Python for almost a year. Moreover, I love the way this video is formatted and how this concept is explained. It's wonderfully easy to understand. I've liked and favorited this video and subscribed to the channel. Thanks for clearing this up for me!!

    • @svetlanakardan3801
      @svetlanakardan3801 Před 5 lety +1

      same here, i struggled with 'self' but not until I found this tutorial.

  • @crossfarm4146
    @crossfarm4146 Před 4 lety +2

    I think its funny, how there are other "Python Instructional Videos" that get like 500,000 views. and all they do is have some entitled, millenial, bafoons repeat words like "Awesome", " Excited", "Super Cool" during their mediocre explanations. Its like most people want to "feel" like they are learning, without actually learning. These Videos are phenomenal, its literally like having a real tutor, and is designed for people ACTUALLY wanting to learn. It's Well organized and laid out. These are the best

    • @johnphilipjones
      @johnphilipjones  Před 4 lety

      Thank you the feedback is appreciated Best wishes Phil

  • @Adks007
    @Adks007 Před 2 měsíci

    The quality of the video, animation, editing and the python tutorial was way ahead of the time. Huge respect to you Phil!!

    • @johnphilipjones
      @johnphilipjones  Před 2 měsíci

      Thank you for the positive comments.
      Best wishes Phil

  • @InfraredVisuals
    @InfraredVisuals Před 2 lety +3

    The demonstration & the animated slides are so elegant and thus simple to understand. Thank you so much.

    • @johnphilipjones
      @johnphilipjones  Před 2 lety +3

      Thank you for the positive feedback it is appreciated.
      Best wishes
      Phil
      (John Philip Jones)

  • @Waterbottles711
    @Waterbottles711 Před rokem +1

    Thank you so much for going over self in details. Makes complete technical sense now that I see it like this. Codecademy didn't really explain it at all.
    You printing the ID also solidified it even more.
    This really helped me so much.

    • @johnphilipjones
      @johnphilipjones  Před rokem

      Thank you for the positive feedback it is appreciated.
      Best Wishes
      Phil.

  • @devinosborne3396
    @devinosborne3396 Před 3 lety +2

    This is the best understanding of self/this and any other explination of OOP programing i've ever even heard of...

  • @ChillinAtDaClub
    @ChillinAtDaClub Před 8 lety +17

    I've struggled with this particular concept since I started learning programming a few years ago. You just made it click. Thanks for the great video!

    • @johnphilipjones
      @johnphilipjones  Před 8 lety +6

      +ChillinAtDaClub Thank you for your generous comments. Glad they are helping.
      Best wishes
      Phil
      (John Philip Jones)

    • @dimitriosdesmos4699
      @dimitriosdesmos4699 Před 7 lety +2

      You are becoming famous on the internet

  • @michaelraj1316
    @michaelraj1316 Před 8 lety +5

    When compared to learning by reading a book and your videos, I can say these videos are awesome. The pictorial examples made it very easy to understand. Thanks a ton for the patience and effort in explaining the concepts so clearly.

  • @ibtesumrezaaninda323
    @ibtesumrezaaninda323 Před rokem +1

    This is undoubtedly the best explanation I have seen so far!! Hat's off! Lots of love and respect for you!

  • @tausal1
    @tausal1 Před 5 lety +3

    I am amazed by the clarity of this video. This has gotta be the best explanation on self. Thank you!

  • @santiagomedinafiguera7280

    This one of the best explanations on the whole Internet. So clear and concise.

  • @john-junkarsan4671
    @john-junkarsan4671 Před 6 lety +5

    Best presentation about the "self" in python! your explanation is also very clear. Thanks !

  • @et_phonehome_2822
    @et_phonehome_2822 Před 7 lety +2

    Thank you for your videos, this is the first time I understand "self". A picture is worth a thousand words, and you have proven it video after video.

  • @etsAdnan
    @etsAdnan Před 10 měsíci +1

    To be honest no one can taught like him ❤❤ thankYouSir

  • @alokjoshi4861
    @alokjoshi4861 Před 4 lety +2

    Best explanation of self! please keep on posting videos like this, great help for the beginners!

  • @LonglongGuitar
    @LonglongGuitar Před 7 lety +3

    this series of videos are like the savior for those beginners, epic work!!!!!! man !

    • @johnphilipjones
      @johnphilipjones  Před 7 lety +1

      Thank you for the positive comments.Check out the supporting website at:
      www.pythonbytesize.com/
      Regards
      Phil
      (John Philip Jones)

  • @captainsparrow00
    @captainsparrow00 Před 4 lety +1

    You must have worked hard to put this together (and all the others lessons).
    Your work helped me a lot to understand how python works.
    I just want to say thank you from Italy

    • @johnphilipjones
      @johnphilipjones  Před 4 lety +1

      Thank you for the feedback it is appreciated. Check out the website at the following link: www.PythonByteSize.com
      I hope to visit Italy when this pandemic is over.
      Best wishes
      Phil

  • @tupG
    @tupG Před 7 lety +3

    Thank you very much for the tutorial. It is brilliant! I really like the way you 'hammer in' all the concepts and terminology again and again.

  • @thesambajaj
    @thesambajaj Před 3 lety +2

    A teacher who knows in advance which questions can arise in the student's mind.... and removing that doubt also. Superb JPJ. Thanx

    • @johnphilipjones
      @johnphilipjones  Před 3 lety +1

      Thank you for your positive feedback.
      Best wishes
      Phil

    • @johnphilipjones
      @johnphilipjones  Před 3 lety +1

      It is good to know that the videos are helping. Thank you for your generous comments
      Best wishes
      Phil

  • @ko95
    @ko95 Před 4 lety +1

    the id builtin looks super useful, and it makes sense that the self parameter in the method gets assigned the object ID derived from the builtin, thanks for a great lecture john!!

  • @kleiben
    @kleiben Před 4 lety +1

    I have been stuck on this concept for days and all other explanations do little to nothing to help clarify this concept. You have made it easy as pie. Well done and keep up your high quality content.

    • @johnphilipjones
      @johnphilipjones  Před 4 lety +1

      Thank you for the positive feedback it is appreciated. The supporting website groups the videos see link below:
      www.PythonByteSize.com
      Best wishes
      Phil

  • @davissmith8846
    @davissmith8846 Před 3 lety +1

    So helpful... you definitely saved me here. Thanks so much!

  • @harishgudipati9666
    @harishgudipati9666 Před 7 lety +2

    Finally understood self with this video after n number of attempts with other sources..Thanks John

  • @TheArchaeus6
    @TheArchaeus6 Před 6 lety +1

    Best explanation I have come across. Very clear. Thank you.

  • @chisomchuba9672
    @chisomchuba9672 Před 4 lety +1

    I'm so lucky to find this tutorial video

  • @cds9195
    @cds9195 Před rokem +1

    Thank you sir. I truly appreciate your concise explanation of this topic.

  • @greenparksandblueskies9099

    Thanks for the superb explanation. Made it really clear.

  • @simonj3342
    @simonj3342 Před 7 lety +5

    Great explanation!

  • @martinkaspar5095
    @martinkaspar5095 Před 5 lety +1

    keeep up the superb work - it rocks - you are the man!!!!!!

  • @aboutgames8326
    @aboutgames8326 Před 6 lety +1

    Really Thank you for your way and method tutoring python programing concepts, greetings with love

  • @liamharris2022
    @liamharris2022 Před 6 lety +2

    Very good video. I have been struggling to understand the concept. It will take another watch or two, but it is the best explanation i have yet.
    massive thumbs up Thank you.

  • @jeuxdeau2009
    @jeuxdeau2009 Před 5 lety +1

    Beautiful explanation. Thank you !

  • @soundrider20z
    @soundrider20z Před 7 lety +3

    Amazing Material !! Thank you very much :)

  • @GM-qv1ql
    @GM-qv1ql Před 2 lety +1

    Brilliant explanation! Kudos on such a great job of simplifying things. The animation is worth the effort. Thank you!

    • @johnphilipjones
      @johnphilipjones  Před 2 lety

      Thank you for your positive feedback.
      Best wishes Phil

  • @CalinColdea
    @CalinColdea Před 5 lety +1

    Fantastic explanation!!!

  • @AdilMadiii
    @AdilMadiii Před 5 lety +1

    Amazing video and very good to understand self :D

  • @ThevideOoLoadeR
    @ThevideOoLoadeR Před 2 lety +1

    Best explanation ever

  • @SuperBhavanishankar
    @SuperBhavanishankar Před 5 lety +1

    I just subscribed with a hope that all other videos have explanation as good as this 👌

  • @pratikjain4704
    @pratikjain4704 Před 6 lety +1

    awesome man... you rock thanks

  • @MirzokhidMukhsidov
    @MirzokhidMukhsidov Před 3 lety +1

    Amazing !

  • @mattaikay925
    @mattaikay925 Před 6 lety +1

    Thanks John for the excellent video - hope you follow with more of the same.

  • @gauravmishra8823
    @gauravmishra8823 Před 3 lety +1

    This is just another appreciation comment, I've become a huge fan of your teaching skills, the way you explain things is just phenomenal, sir I want to know whether you've the notes of the following videos, if yes then please let us know .

    • @johnphilipjones
      @johnphilipjones  Před 3 lety

      I hope you collate the notes into a suitable format in the not to distant future.
      Best wishes Phil

    • @johntobin9404
      @johntobin9404 Před 3 lety

      You can obtain the transcript of the videos on the same page as this video. Click the ... elipses beside the Save button and then just click 'Open Transcript.'

  • @iloveamoos
    @iloveamoos Před 4 lety +2

    Dude you rock !

  • @phenompunk2336
    @phenompunk2336 Před 5 lety +1

    Sir u are the best make more videos on python these videos helped me a lot thanks a lot
    And i subscribed

  • @armanigiles4953
    @armanigiles4953 Před 6 lety +1

    Thank You

  • @kishorekumar2769
    @kishorekumar2769 Před 6 lety +1

    Very clear :)

  • @RNGoD
    @RNGoD Před 7 lety +1

    thank you

  • @sukhendutarafder381
    @sukhendutarafder381 Před 6 lety +1

    Thanks a lot

  • @sososong3438
    @sososong3438 Před 7 lety +1

    great

  • @RABWA333
    @RABWA333 Před 6 lety +1

    thanks

  • @fillerchatter7612
    @fillerchatter7612 Před 4 lety

    I am just clarifying my understanding.
    A class method exists in its own right. Though, when you create an object of that class, the method exists in its own right inside the object too.
    That's why when you define the class, you use self within the parameters, so that when you construct the object, it knows to use the method internally within that object that exists in its own right. Essentially using the ID number passed inside to it "self"?

    • @johnphilipjones
      @johnphilipjones  Před 4 lety +1

      The method is defined in the class with the self as you have described. This allows each instance of the class (i.e. object) to effectively have there own copy of the method.
      There is an issue with the language used to define class and instance methods which is best avoided.
      If you see a class that has methods declared (defined) using self then they are capable of ensuring each object effectively have their own copy.
      If self is not used then this will result in each object not being able to have their own copy.
      However, the method can still be executed by referencing the class name. But this type of coding should be avoided.
      Best wishes Phil

  • @blenderm4n
    @blenderm4n Před 6 lety +1

    So it's basically a replacement for static and not static in other languages? Excellent tutorial, a bit wordy though.

  • @justgivemethetruth
    @justgivemethetruth Před 8 lety +1

    Why does every Python book have some kind of mangled explanation of this parameter, and yet none of them that I have run across really explain it well.
    It would seem than any object-oriented language would need to do this in some way, so would it be fair to say that Python just makes this explicit to remind the programmer what is happening? If so, is there any actual use for this parameter or tricks you can play with this parameter? What is the motivation for having that there?
    By the way, thanks. Very clear and step-by-step explanation.

    • @johnphilipjones
      @johnphilipjones  Před 8 lety +3

      +justgivemethetruthOther languages use something similar for example "this" and "me". Python uses it explicitly as it is possible for a function to be a function in a class or a method. If it is a method then you have to use "self" then this makes it a piece of code tied to the instance of the class. If you do not use "self" then you can message the class directly to invoke the method. However, I would not recommend accessing the class directly. Keep a class back for its main purpose that is as a template for creating objects.
      “Self” is used extensively within the class definition for example it is used to create variables that will be instance variables i.e. variables that “belong” to the instance (object) of the class.
      Regards
      Phil
      (John Philip Jones)

  • @dillyjackfeva6035
    @dillyjackfeva6035 Před 6 lety

    Great video and explanation. One question I have programmed in java and when u define a class in java it’s understood all the attributes and methods defined in the class will be a object one day. The class-type variable then is used to reference which particular object in a method call.
    So my question is, is python doing the same thing as java behind the scenes but requires the programmer to explicitly use the self parameter to tie to objects, why not just use the object names to reference the method?
    Long winded question From me my apologies but I like clarity ,because then I truly understand what’s happening. And this has been the first head scratcher I encountered in python like some others have said. Any response will help thank you!

    • @johnphilipjones
      @johnphilipjones  Před 6 lety +1

      Have a look at the following videos which address this issue.
      www.pythonbytesize.com/video-pythons-self-parameter.html
      www.pythonbytesize.com/video-python-method-parameters-and-self.html
      www.pythonbytesize.com/video-a-python-instance-method.html
      Best wishes
      Phil

  • @harishkumarb.c.8369
    @harishkumarb.c.8369 Před 6 lety

    Hi really it is great explanation. is there any document is available for python tutorial . if there it will be helpful. thank you so much for.....

  • @srinidhiskanda754
    @srinidhiskanda754 Před 8 lety +1

    tank you so much sir, lovely explanation. i am from java where it don't explicit mention about "self" keyword for method definition of class, is it hided from method definition and also why in python we have to explicit mention ? is there any advantage by doing so?

    • @johnphilipjones
      @johnphilipjones  Před 8 lety

      You can create more than one object from a class. Each object needs to be separately identifiable and self is used to achieve this i.e. each object has their own copy of self and each self contains a 'code' that is different in each case. This way each of the unique objects based on the same class can be identified. It is worth noting that self is not a reserved word. It is just standard practise to use self. You can choose another word and the program will still work - however do not do this always use self.
      Best wishes
      Phil

    • @srinidhiskanda754
      @srinidhiskanda754 Před 8 lety +1

      thank you

  • @theto6
    @theto6 Před rokem +1

    TE AMO

  • @AliG.G
    @AliG.G Před rokem

    Can you make tutorials of kivy, kivymd and kaki hotreload with multiple kv and py files? That will be an epic series.

  • @rogerbak4978
    @rogerbak4978 Před 4 lety +1

    Wow! Wow Mr. JONES! You're the best! A very good teacher!!! I love all of your videos! Thank you very much!
    Could I please have your contacts if you don't mind! Thanks in advance!

    • @johnphilipjones
      @johnphilipjones  Před 4 lety

      Can be contacted via the following link:
      www.pythonbytesize.com/contact.html
      Best wishes
      Phil

    • @rogerbak4978
      @rogerbak4978 Před 4 lety

      Thanks a lot Mr JONES!!!

    • @rogerbak4978
      @rogerbak4978 Před 4 lety

      I try but I can not access to the site. The link does not work

    • @johnphilipjones
      @johnphilipjones  Před 4 lety

      Try the following link and then click on the 'Contact' menu item
      www.pythonbytesize.com
      Best wishes
      Phil

  • @jamesmccannon7769
    @jamesmccannon7769 Před 5 lety

    This seems to clarify a lot. However what I don't understand is that on python 3 when I copy your code out and leave 'self' out of the code, it still works without the error you said you would receive. Why is that? This is my code
    class calculation:
    ##
    ## def two():
    ## one = input('Type number 1: ')
    ## two = input('Type number 2: ')
    ##
    ## ans = int(one) + int(two)
    ## print(ans)
    ##
    ## def hello():
    ## print('HI')
    ##
    ##
    ##clacultion = calculation()
    ##calculation.hello()

    • @johnphilipjones
      @johnphilipjones  Před 5 lety

      As you have not used self the functions in the class belong to the class. The last line of your code is messaging the class not an object (the name of object is a different spelling in your code) so the code works. As your code stands you are not following object oriented coding. I.e. you will not be able to make objects of the class that work.
      Best wishes
      Phil

  • @martinkaspar5095
    @martinkaspar5095 Před 5 lety

    would you create a video tutorial that covers the dot-operator - that would be just great!!

    • @johnphilipjones
      @johnphilipjones  Před 5 lety

      Have a look at the following video:
      www.pythonbytesize.com/video-pythons-self-parameter.html
      and all the videos at the following playlist.
      www.pythonbytesize.com/classes-and-objects1.html
      The dot operator is referred to throughout this playlist on classes and objects.
      Best wishes
      Phil

  • @JohnnyJazzFreak
    @JohnnyJazzFreak Před rokem

    Quick question, Phil. When you said that the demo_method within the class exists in its own right, AND my_object, the instantiated object based on the class, ALSO exists in its own right, do I understand correctly that now we have TWO independent instances of the demo_method, and have a copy of the demo_method within my_object?

    • @johnphilipjones
      @johnphilipjones  Před rokem

      That is a good question and one that engages my interest as I started off my career as a machine code programmer (I am an Electronic Engineer). However, it is not something I have investigated (yet).
      What I can say is every Python object has its own identifier that can be found by using the id() function. So, every instance of the class (i.e. object) is unique. Internally there may be some sharing of the code with each pointing to its own objects data. However, this is me just surmising.
      Looking at the issue from the perspective of a Software Engineer (I moved on from Electronic Engineering to Software Engineering) the objects are regarded as totally independent regardless as to how the compiler sets up the environment.
      To design an object-oriented software system would typically require the use of the Unified Modelling Language (UML). The artefacts of this language (at least the ones I use) show the software runtime as a community of objects communicating with each other via messages. You would typically use a collaboration or communication diagram to show this communication between objects. To fit in effectively with the design artifacts offered by UML it is important to regard objects as totally independent of each other.
      Many people will criticise object orientated programming because they do not view software systems as communicating objects.
      There are of course other methodologies for writing software that do not require an object-oriented approach.
      To fully appreciate the object-oriented development across the full software life cycle requires the belief (in my view) that objects are independent and together form a community were individual objects request services of each other by sending messages.
      Of course, Python supports numerous software development paradigms. This offers flexibility as a language but does not often help support a consistent development paradigm.
      I am not sure that this answers your original question, but it will hopefully give an insight into why I believe regarding objects as separate entities based on a class is more important.
      I hope this helps.
      Best wishes
      Phil
      (John Philip Jones)

    • @JohnnyJazzFreak
      @JohnnyJazzFreak Před rokem +1

      @@johnphilipjones Thanks Phil. Very detailed answer. It's just that initially I interpreted that there WERE indeed two objects but now it seems you are reluctant to state that with certainty. I understand things in step-wise fashion. I work in the American 9-1-1 network industry, the equivalent of Britain's 999.
      The network is enormously complex, with mind-boggling detail. If there wasn't a way to understand things at a high level, in terms of call flows, it would be overwhelmingly, and chaotically senseless to the average learner. I adore the way you teach because it's step-wise at a logical level.
      Many people, when teaching, they skip steps. And an all too common thing in python CZcams videos, is that the tutor is flying, nay whizzing through the material and on top, is managing two separate files. Then suddenly, you are lost and you say, wait. Where is that? Where did he just go to?
      What's happened is that the tutor switched file without telling the audience. Someone that's in tune with their audience will say: "Now we will switch to file 2 and we'll create a method to call file 1" so we know where they are. I can't count the number of times I've had to slow down a video. Wait! What! It's exasperating.

    • @JohnnyJazzFreak
      @JohnnyJazzFreak Před rokem

      Lastly, can you confirm I have this straight? When we put (self) in as a parameter to the demo_method(), when the code runs, my_object.demo_method messages my_object, then invokes the demo_method that runs inside the class.
      But how exactly do my_object and demo_method interact? What does that handshake look like, at a high level? Here is the way I'm reading what's happening:
      my_object passes self to the demo_method, and then demo_method says:
      "-Oh. I see you just passed your self to me (though invisibly and not explicitly in the code). As it turns out, I, demo_method also have one of those self IDs. I was able to read yours, and see that your self ID and my self ID are identical, so you belong to the same class that I'm part of and I can see that you want me to execute myself" (not in French Revolution style). Is that a good paraphrasing?

    • @johnphilipjones
      @johnphilipjones  Před rokem

      I consider the objects and self as follows:
      The class defines the attributes (data) and behaviours (methods) of any object that is based on the class. Let's assume we have a class called ClassA. Two instances of this class are created, by that, I mean two objects. Let's call these objects ObjectX and ObjectY.
      The class has a behaviour defined i.e method. This method is called DemoMethod(). This method has code to perform the required task of the method. In addition, the method has local variable to hold intermediate values of data produced during its execution. Methods are usually sent data to process and it is likely that this data will be different for the method ‘inside’ ObjectX and ‘inside’ ObjectY.
      Now ObjectX and ObjectY will both have the behaviour of the DemoMethod() as it was defined in ClassA. However, they have just received different data sent to their own copy of the DemoMethod().
      Lets say that the DemoMethod() as it exists within ObjectX is executing and an interrupt occurs that has to be serviced. The DemoMethod() is forced to suspend its execution and the interrupting process is executed. Once the interrupting process has finished, execution is returned to the exact same place in the interrupted DemoMethod() so it can finish its execution. Now if ObjectX and ObjectY are in existence during runtime there will in effect be two DemoMethod()’s. However, these methods are from Pythons viewpoint different because they both have been identified by the id of the object to which they belong. So, each method (that is based on the same class) are unique and their uniqueness is achieved by them having the id of the object passed to self.
      I would therefore recommend that you regard the objects as being separate entities that have had their attributes and behaviour defined (or declared) by the class. However, for example, the attributes can hold different values for each of the objects. Both objects will have the same number of attributes as defined in the class, but these attributes can hold different values for each of the objects. For example, the details on a bank customer would typically be the name, address and bank balance etc. The details required for each customer will be defined in a class. Every customer of the bank will have themselves represented buy an instance of this class (that is an object). Every object would have their own value in the name attribute, their own value in the address attribute, and their own value in the bank balance attribute.
      So, in conclusion I recommend you regard objects as different entities existing in their own right. This will fit in well with the UML design techniques when developing software systems. However, I am unable to indicate how objects manifest at runtime with respect to the heap and stack mechanism because unfortunately I do not know. What I can say is that if you do not use self in the definitions of the method header the method cannot exist separately within each object created.
      Hope this helps.
      Best wishes
      Phil

    • @JohnnyJazzFreak
      @JohnnyJazzFreak Před rokem

      @@johnphilipjones That's a great explanation, Phil. This can be a tricky topic to talk about, so thanks for expanding it (my brain!)

  • @taofeeqomotolani2311
    @taofeeqomotolani2311 Před 2 lety +1

    Wow, that's all I can say.

  • @srinidhiskanda754
    @srinidhiskanda754 Před 7 lety

    why we need class concept in python. Instead we can use modules that can act as a class. for example in java we use class variable to get access to its field and methods. but in python we can use module name to access variable and methods inside that module. what the advantage of using class concept in python

    • @johnphilipjones
      @johnphilipjones  Před 7 lety +2

      A module groups functions and data structures into logical collections. If you used a data structure in a module it will be shared by all code within the module. You create instances of classes (i.e. objects) and each object can have its own copy of data structures. This is not possible with modules. Also, the object oriented development process is different to the procedural approach i.e. they are different paradigms. Consequently there is a different development process across the life-cycle for analysis, design and implementation.

  • @srinidhiskanda754
    @srinidhiskanda754 Před 8 lety

    why object is created outside class indention can we create instance inside class indention. forgive me for this silly question since i am from java we used to create instance inside class

    • @johnphilipjones
      @johnphilipjones  Před 8 lety +2

      I am not 100% sure what you are asking here. You can create an instance of a class from within a class definition. Hope that helps.

    • @srinidhiskanda754
      @srinidhiskanda754 Před 8 lety +1

      tank you

    • @Colstonewall
      @Colstonewall Před 7 lety +1

      That's how Python works. The Class is the blueprint for the object. So to create the object it must be done outside the class. I believe in Java, the objects are created inside the class, it's NOT like this in Python. .
      Objects are created OUTSIDE the class definition, unlike Java

    • @srinidhiskanda754
      @srinidhiskanda754 Před 7 lety

      thank you for the info