For technical reasons I was unable to respond to this earlier.
Executing "range = 100" means that you've changed the interpretation of
"range" to be a label for the integer constant "100", so that when you
then try to loop over range the original interpretation (make a list) has
been lost.
However, use of "range" in a list of function arguments doesn't redefine
its meaning outside that domain.
Bruce Sherwood
--------------------------
I have been studying Vpython modules Text and Controls and I
am a little confused by the use of 'range'. The __init__ parameter
list looks like this:
> > def __init__(self, x=0, y=0, width=300, height=320,
> > range=100,title=None, foreground=None, background=None):
> >
> > Now RANGE is of course a keyword, but it is being used here as a
> > variable.
> >
> > Using IDLE 1.2.2 produces the following error.
> >
> > range=100
> > ......
> > for a in range(1,10):<br>
> > .....
> > TypeError: 'int' object is not callable<br>
> >
> > Am I missing something?
|