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


Groups > comp.lang.python > #66739

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

Date 2014-02-20 01:04 -0800
From Gary Herron <gary.herron@islandtraining.com>
Subject 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>
Newsgroups comp.lang.python
Message-ID <mailman.7177.1392887498.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 02/20/2014 12:26 AM, ApathyBear 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)
>
> can a similar line look like this?:
> temp1.pop(0) = Athlete(temp1.pop(0),temp1)

First some notation:  You are not creating a class, but rather in 
instance of a class.  The  code
   class Athlete:
     ...
  created the class, and now you are ready to create (many?) instances 
of that class.

A call like
     Athlete(...)
will create an instance of that class with whatever parameters you 
supply.  What you do with that instance after it is created is your 
choice.  Assignment is one possibility, but many other operation are 
also possible:

     x = Athlete(...)
     print( Athlete(...) )
     Athlete(...)+Athlete(...) # If addition made any sense and was 
implemented in the class
     return Athlete(...)
     ...


Gary Herron

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