Path: csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'attribute': 0.07; 'subject:code': 0.07; 'attributes': 0.09; 'caller': 0.09; 'function:': 0.09; 'instance.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'try:': 0.09; 'def': 0.12; 'wrote': 0.14; 'above?': 0.16; 'afterwards': 0.16; 'declaration': 0.16; 'defined.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:skip:u 10': 0.16; 'thursday,': 0.16; 'wrote:': 0.18; 'saying': 0.22; 'creating': 0.23; 'equivalent': 0.26; 'asking': 0.27; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'chris': 0.29; '[1]': 0.29; 'statement': 0.30; 'code': 0.31; 'usually': 0.31; 'class': 0.32; 'this.': 0.32; 'skip:d 20': 0.34; 'problem': 0.35; 'something': 0.35; 'there': 0.35; 'really': 0.36; 'executing': 0.36; 'doing': 0.36; 'whatever': 0.38; 'to:addr :python-list': 0.38; 'fact': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'skip:a 30': 0.61; 'new': 0.61; "you're": 0.61; 'refer': 0.63; 'our': 0.64; '20,': 0.68; 'skip:r 40': 0.68 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: Cannot figure out line of code, also not understanding error Date: Thu, 20 Feb 2014 11:50:10 -0500 (EST) Organization: news.gmane.org References: X-Gmane-NNTP-Posting-Host: wsip-68-106-144-188.dc.dc.cox.net X-Newsreader: PiaoHong Usenet NewsReaders 1.36 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392914798 news.xs4all.nl 2840 [2001:888:2000:d::a6]:55350 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66774 ApathyBear Wrote in message: > > 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? > The code you're describing is inside a function: def get_coach_data(filename): try: with open(filename) as f: data = f.readline() temp1 = data.strip().split(',') return Athlete(temp1.pop(0),temp1.pop(0), temp1) So the caller might be doing something like x = get_coach_data ("myfile.txt") The return statement you're asking about returns a new instance of Athlete, which gets assigned to x. Then you may try x.data or equivalent if you like. -- DaveA