Skip to content Skip to sidebar Skip to footer

I Have A Compiler Error "not Defined" Although There Is A Definition

from gasp import * GRID_SIZE = 30 MARGIN = GRID_SIZE BACKGROUND_COLOR = color.BLACK # Colors we use WALL_COLOR = (0.6 * 255, 0.9 * 255, 0.9 * 255) # The shape of the maze.

Solution 1:

The unfinished call to Circle() is probably the result of an error trying to format the code properly. Please check that you post the code that you actually ran, and the traceback is the one that you actually got (there's some of this one missing!).

The error reported in the (horribly formatted) traceback is that neighbors is undefined in the line for neighbor in neighbors:. There is absolutely no way the compiler would munch its way through the intervening lines

(x, y) = self.placeneighbors= [ (x+1, y), (x-1, y)]

without some other kind of error.

Note: the above was in response to another question that was closed as I was answering it. I am leaving it in so that you know that the advice that you got for that question was wrong.

I suspect that after your FIRST question (width not defined in line for x in range( width ):), you didn't fix all your indentation errors, and the Q2 and Q3 line for neighbor in neighbors: should be shifted 4 spaces to the right of where it appears to be.

Do you have any tabs in your source files? If so, get rid of them. If you are not sure about how to stay tab-free, ask a separate question, say what editor and what OS and maybe someone familiar with that combination can help you.

How to find tabs in your source file:

C:\junk>\python27\python -c "print[x for x in enumerate(open('sometabs.py'),1)if'\t'in x[1]]"
[(1, 'foo\tbar\n'), (3, '\t\toof\n')]

Solution 2:

I don't see where the error is immediately. Have you recently moved around files such that an import isn't really running your new code, but actually running a .pyc file instead? For example, did you recently introduce a package with the same name as a python file?

.
\- main.py           Has an "import stuff"
\- stuff.py          This is the code you think is being run.
\- stuff
   \- __init__.py    This code is being run.

Post a Comment for "I Have A Compiler Error "not Defined" Although There Is A Definition"