>   egold = 0:
>   while egold < 10:
>     if test():
>       ego1d = egold + 1
> 

Both pylint and pychecker pick this up.  I wrapped the code in a
function (to prevent importing from running in an infinite loop) and ran
both pylint and pychecker:

plyint: W:  5:myfunc: Unused variable 'ego1d'
pychecker: test.py:4: Local variable (ego1d) not used


I make a habit to run pylint or pychecker on my code often.  They pick
up a lot of stuff like unused variables, etc.

But you can also do this:

/* initialize variables i'm gonna use */
int vara = 0; 
int varb = 0;
while (vara < 10) {
    varb = vara + 1;
}

So we can make a similar mistake in C if you type the wrong (declared)
variable name.  Moreover, "gcc -Wall" did not report the "unused"
variable so it might be even more difficult to track down the problem. 


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to