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


Groups > comp.lang.python > #66738

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

References <da9b6b96-7e9a-4094-a3f4-74cdedaf869e@googlegroups.com> <e0d070e3-703b-4583-a845-a530b8302e1b@googlegroups.com>
Date 2014-02-20 19:54 +1100
Subject Re: Cannot figure out line of code, also not understanding error
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.7176.1392886498.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Feb 20, 2014 at 7:26 PM, ApathyBear <nirchernia@gmail.com> wrote:
> Thanks for pointing out the missing parenthesis, it makes sense now why there was an error.
>
> I suppose my question now is (and forgive my ignorance about classes, this is my first time learning them) why is it calling Athlete with some arguments? In order to make a class object, don't you need to create an instance by assigning a class to something?
>
> like:
>  x = Athlete(temp1.pop(0),temp1.pop(0),temp1)

Calling a class will create a new instance of it. [1] What you do with
it afterwards is separate.

The return statement takes any value and, well, returns it. You can
return anything - an Athlete instance, the integer 13423523452, the
floating point value NaN, anything at all.

> can a similar line look like this?:
> temp1.pop(0) = Athlete(temp1.pop(0),temp1)

You can't assign to a function call, so no, you can't do that.

I recommend you start with the Python tutorial:

http://docs.python.org/3/tutorial/index.html

ChrisA


[1] The class might choose to do something different (when you call
bool with some argument, it'll return a pre-existing True or False),
but conceptually, you still get back an instance of that class.

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