Python Forum

Full Version: error 'ring' is not a callable object
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to get the ball to fly through a series of rings, but I keep getting this error message 'ring' is not a callable object.  The strange thing is when I run the code, I get a single ring and two spheres. I'm guessing it has to do with the way it's set up in the loop, but I don't know why the ring would be any different than the sphere.  
Thanks

from visual import *

myuniv = display(range=vector(6,6,6))

s = vector(0,1.1,0)
v = vector(9.5,0,0)
a = vector(0,-9.8,0)

t = 0.0
dt = 0.05

ball = sphere(pos=s,radius=.3,color=color.cyan)

while s.y > -.2:
    s = s + v*dt
    print ('s=',s)
    v = v + a*dt
    t = t + dt
    ball.pos = s
    ballghost = sphere(pos=s,radius=.2)
    ring = ring(pos=s,axis=v,radius=1.0,color=color.red)
(May-02-2017, 04:45 AM)JakeWitten Wrote: [ -> ]
    ring = ring(pos=s,axis=v,radius=1.0,color=color.red)

You're getting one ring, and then an error, because the first time through the loop you call ring()... and then overwrite the "ring" function by assigning something to the variable. Rename your variable (or just don't assign ring()'s output, since you don't use it anyway), and it might work.