Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:error': 0.03; 'subject:not': 0.03; 'tutorial': 0.03; 'assign': 0.07; 'attribute': 0.07; 'subject:code': 0.07; 'attributes': 0.09; 'instance.': 0.09; 'method,': 0.09; 'cc:addr:python-list': 0.11; '__init__,': 0.16; 'above?': 0.16; 'afterwards': 0.16; 'declaration': 0.16; 'defined.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:skip:u 10': 0.16; 'thursday,': 0.16; 'wrote:': 0.18; "python's": 0.19; 'thu,': 0.19; 'feb': 0.22; 'saying': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'exists': 0.24; 'refers': 0.24; 'cc:2**0': 0.24; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; '[1]': 0.29; 'message-id:@mail.gmail.com': 0.30; 'usually': 0.31; 'object.': 0.31; 'class': 0.32; 'this.': 0.32; 'quite': 0.32; 'moment': 0.34; 'problem': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'executing': 0.36; 'explains': 0.36; 'should': 0.36; 'whatever': 0.38; 'fact': 0.38; 'pm,': 0.38; 'does': 0.39; 'how': 0.40; 'even': 0.60; 'new': 0.61; 'name': 0.63; 'refer': 0.63; 'our': 0.64; 'linked': 0.65; '20,': 0.68; 'skip:r 40': 0.68; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=r6y544NK+il8GiZdSiaqhY3vpU3pVPmpBq8+YF1vWmg=; b=l96dg96X1ZV6yLTj5+4OM254t7w3IjBNgW1CWNONIaMwfRvec/MkiSl6TgX/Tc+Y4O 4Y04XfcA6XdyqKls/KbkDrkFvgcL2dZmTfscmnfQuoAIpOOP5+OVYrcTVV8TMGJ984gK cK48uFZPgKaaC9zvXhnSnFzONaEZ/KvWhIbOxe8pdEAmjOWlvFdZXYNHIA9hRyZ+FTVZ xR3MtBXeUsEY1y71/dIoyJFISZLPtUD2BkrC02w/u6QKcrdoSOHFXMfjyWxCd7jUMDj0 txvYMSyvd1Gs7/1Xeue0CmWZvqVoaeowRJVgJBo3nI4/ny7sGZfR5r+Tigd5S7eBSxH6 nJYA== MIME-Version: 1.0 X-Received: by 10.68.247.6 with SMTP id ya6mr851998pbc.45.1392889297369; Thu, 20 Feb 2014 01:41:37 -0800 (PST) In-Reply-To: References: Date: Thu, 20 Feb 2014 20:41:37 +1100 Subject: Re: Cannot figure out line of code, also not understanding error From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392889300 news.xs4all.nl 2925 [2001:888:2000:d::a6]:45646 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66742 On Thu, Feb 20, 2014 at 8:22 PM, ApathyBear 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