[Tutor] Out of range

alan.gauld@bt.com alan.gauld@bt.com
Tue Feb 4 15:19:22 2003


> >> as there is no name index in Python (unless you define it).
> 
> There is actually. In a little loop in a function, ....
> 
> The bother is that, as shown, it wouldn't let me print the index. 

If its defined in a function then you can't see it outside of 
that function. You need to use a debugger to stop execution inside 
the function and print it in the debugger(IDLE's debugger or 
pdb will both do that happily)

Alternatively just put a temporary print statement in.
If its a long loop then maybe only print occasionally:

if not index % 5: print index    # print every 5th time 


Alan G.