Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #66742

Re: Cannot figure out line of code, also not understanding error

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 <rosuav@gmail.com>
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 <ef956f04-414f-47ff-a813-bfa1152d2f29@googlegroups.com>
References <da9b6b96-7e9a-4094-a3f4-74cdedaf869e@googlegroups.com> <ef956f04-414f-47ff-a813-bfa1152d2f29@googlegroups.com>
Date Thu, 20 Feb 2014 20:41:37 +1100
Subject Re: Cannot figure out line of code, also not understanding error
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.7179.1392889300.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Thu, Feb 20, 2014 at 8:22 PM, ApathyBear <nirchernia@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Cannot figure out line of code, also not understanding error ApathyBear <nirchernia@gmail.com> - 2014-02-19 23:32 -0800
  Re: Cannot figure out line of code, also not understanding error Chris Angelico <rosuav@gmail.com> - 2014-02-20 19:03 +1100
  Re: Cannot figure out line of code, also not understanding error Vincent Vande Vyvre <vincent.vandevyvre@swing.be> - 2014-02-20 08:56 +0100
  Re: Cannot figure out line of code, also not understanding error ApathyBear <nirchernia@gmail.com> - 2014-02-20 00:26 -0800
    Re: Cannot figure out line of code, also not understanding error Chris Angelico <rosuav@gmail.com> - 2014-02-20 19:54 +1100
    Re: Cannot figure out line of code, also not understanding error Gary Herron <gary.herron@islandtraining.com> - 2014-02-20 01:04 -0800
  Re: Cannot figure out line of code, also not understanding error ApathyBear <nirchernia@gmail.com> - 2014-02-20 01:22 -0800
    Re: Cannot figure out line of code, also not understanding error Chris Angelico <rosuav@gmail.com> - 2014-02-20 20:41 +1100
    Re: Cannot figure out line of code, also not understanding error Dave Angel <davea@davea.name> - 2014-02-20 11:50 -0500
  Re: Cannot figure out line of code, also not understanding error ApathyBear <nirchernia@gmail.com> - 2014-02-20 02:13 -0800

csiph-web