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.


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to