Cannot figure out line of code, also not understanding error
gary.herron at islandtraining.com
Thu Feb 20 10:04:50 CET 2014
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?
> 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
created the class, and now you are ready to create (many?) instances
of that class.
A call like
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
x = Athlete(...)
print( Athlete(...) )
Athlete(...)+Athlete(...) # If addition made any sense and was
implemented in the class
More information about the Python-list