[Tutor] Unbound Method Error

Greg Nielsen gollumgreg407366 at gmail.com
Mon Apr 25 22:19:23 CEST 2011


Ramit,

     First, thank you for your input and insight into my problem, I believe
that the code you came up with should not only be more efficient, but also
clear up the last of my issues. I just have a quick question on the
isinstance command you called. How exactly do I get the code to recognize it
as a class I wrote sitting in an imported library file? I would guess that
it would look sort of like this:

       if crash:
           for car in crash:
                if isinstance(car, redracersprites26.BlueCarSprite()):
                    redracersprites26.BlueCarSprite.collide(car, playerCar)

However, worded as it the follow error and call back happens:

Traceback (most recent call last):
  File "C:\Users\Greg\Documents\NetBeansProjects\Red Racer
26\src\redracer26.py", line 19, in <module>
    main()
  File "C:\Users\Greg\Documents\NetBeansProjects\Red Racer
26\src\redracer26.py", line 16, in main
    redracerstates26.game(startLives)
  File "C:\Users\Greg\Documents\NetBeansProjects\Red Racer
26\src\redracerstates26.py", line 87, in game
    if isinstance(car, redracersprites26.BlueCarSprite()):
TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and
types
I must be using the wrong syntax in the second argument. I think I should be
able to find the documentation for this (extremely cool) method you showed
me, but if you know the proper way to cite my object, could you send me what
you think will work. This way I can have something to double check my work
against if I don't get it right first time round. Thank you again for your
time and assistance Ramit.

Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110425/688da944/attachment.html>


More information about the Tutor mailing list