Ok I think I got it. Thanks everybody. And sorry for the late reply. My
classes have just started so learned python unfortunately must be bumped
down on the priority list

On Thu, Aug 26, 2010 at 4:32 AM, Alan Gauld <alan.ga...@btinternet.com>wrote:

>
> "Andrew Martin" <amartin7...@gmail.com> wrote
>
>  I want to compare zenith, a floating point number, with the current y
>> value?
>> I thought the current y value could be retrieved by Projectile.getY.
>>
>
> Projectile.getY is a reference to the getY method of the Projectile class.
> (See the separate thread on function objects for more on this topic)
>
> You want to execute the method so you need parens on the end.
>
> But, you also want to execute it for the cball instance.
> You have already done this earlier in your code, here:
>
>    while cball.getY() >= 0:
>>>>>
>>>>
> So you just need to make the if test compatible with that:
>
>
>         if Projectile.getY > zenith:
>>>
>>
> becomes
>
>           if cball.getY() > zenith:
>
> And similarly for the assignment
>
>            zenith = Projectile.getY()
>>>>>
>>>> becomes
>                   zenith = cball.getY()
>
>
> As an aside you can do this using Projectile, but its bad practice:
>
> Projectile.getY(cball)
>
> This explicitly provides the self argument instead of Python doing
> it for you when you use the instance. We can use this technique when
> calling inherited methods inside a class method definition. Anywhere
> else its best to use the instance to call a method.
>
> HTH,
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to