[Tutor] Trouble with exercise regarding classes

Alan Gauld alan.gauld at btinternet.com
Thu Aug 26 01:24:40 CEST 2010

"Andrew Martin" <amartin7211 at gmail.com> wrote

> However, when I did so I got this error: "TypeError: unbound method 
> getY()
> must be called with Projectile instance as first argument (got 
> nothing
> instead) "

>> def main():
>>     angle, vel, h0, time = getInputs()
>>     cball = Projectile(angle, vel, h0)

cball is a Projectile instance

>>     zenith = 0.0
>>     while cball.getY() >= 0:

So this is fine

>>         cball.update(time)

>>         if Projectile.getY > zenith:
>>             zenith = Projectile.getY()

But what are you doing here?
You are trying to compare the getY method of the class with a floating 
point number?
Then you call getY using the class rather than the instance?
I'm confused - and so is Python...

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list