[Tutor] Unbound Method Error
Peter Otten
__peter__ at web.de
Tue Apr 26 09:40:43 CEST 2011
Greg Nielsen wrote:
> if crash:
> for BlueCarSprite in crash:
> redracersprites26.BlueCarSprite.collide(crash, playerCar)
> for GreenCarSprite in crash:
> redracersprites26.GreenCarSprite.collide(crash, playerCar)
> for TruckSprite in crash:
> redracersprites26.TruckSprite.collide(crash, playerCar)
> if crash:
> for car in crash:
> if isinstance(car, redracersprites26.BlueCarSprite()):
> redracersprites26.BlueCarSprite.collide(car, playerCar)
That's too little of your code to be sure, but I have a hunch that you
can avoid the if-crash test and all if-isinstance(...) tests and just write
for car in crash:
car.collide(playerCar)
You rarely need to invoke an unbound method outside of a subclass method.
More information about the Tutor
mailing list