On Thu, Feb 20, 2014 at 8:22 PM, ApathyBear <nircher...@gmail.com> wrote: > On Thursday, February 20, 2014 12:54:54 AM UTC-8, Chris Angelico wrote: > >>Calling a class will create a new instance of it. [1] What you do with >>it afterwards is separate. > > Okay. So what you are saying is that > return(Athlete(temp1.pop(0),temp1.pop(0), temp1)) IS in fact creating an > instance of Athlete. My problem with this is that there really is no > declaration of 'self' for this instance. > > > Usually when I do something like this. > x = Athlete("Henry", "11-15-90", [1,2,3]) > I can refer to things of this instance by executing x.name or whatever other > attributes the class defined. > > If I create an instance with no 'self' how does this make any sense? How > would I get an attribute for the our instance above?
Inside a method, including __init__, self refers to the object. Even if you never assign it to anything, that instance exists somewhere, and self can refer to it. It has an identity from the moment it begins to exist - which is before it ever gets the name 'x' pointing to it. You definitely should work through the tutorial I linked you to; it explains Python's object model quite well. ChrisA -- https://mail.python.org/mailman/listinfo/python-list