[Tutor] Weird Python Error

Danny Yoo dyoo at hashcollision.org
Fri Oct 18 03:02:53 CEST 2013


Hi Zaid,

Your YellowCar will have one once its reset() has been called.  However, I
don't see it in __init__(), so there might be a period of time where it
won't have one.  I haven't traced through possible code paths where this
happens, but I suspect one of them may.  One example may be:

    c = car()
    car.update()

and that would trigger the kind of error you're seeing.

Normally, you want to give all attributes some kind of value in __init__(),
just to keep this sort of weird situation from happening.  All your other
sprites appear to set a 'dy' in their __init__, so symmetry seems
appropriate.




> **
>
> *Now for some reason, it is saying that YellowCar doesn’t have a dy
> variable, when it clearly does. This only happens when it is going from
> level 1 to level 2, I don’t know what happens after level 2 because the
> program keeps giving me the error. Any help would be appreciated.*
>
> **
>


In the future, also make sure to copy and paste the exact error message and
stack trace and show that too.  Not only does it help explain the problem,
but also acts as a way for tutors to make sure they're chasing the same
problem as the one you're interested in.  Otherwise, we might be looking
into other problems that are entirely unrelated to what you're concerned
about.  It's a matter of making it easier for tutors to reproduce what
you're seeing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131017/3c034a6a/attachment.html>


More information about the Tutor mailing list