简体   繁体   English

曲线对象不可调用错误vPython

[英]Curve object is not callable error vPython

I'm new to vPython and Python in general and got this error when I was trying to create a catenoid. 我是vPython和Python的新手,在尝试创建类别时遇到此错误。 I was able to call a curve object earlier in the code that works fine but when I tried to do it a second time using the exact same syntax I get the aforementioned error. 我能够在代码中更早地调用曲线对象,但工作正常,但是当我尝试使用完全相同的语法第二次进行操作时,遇到了上述错误。 I imagine it is a fairly simple error but Id really appreciate if someone could help me out. 我认为这是一个非常简单的错误,但是如果有人可以帮助我,我非常感谢。 The error occurs on line 11. 错误发生在第11行。

from visual import *
import math
curve=curve(color=color.green)
thStep=math.pi/1000
c=10 
theta=0
z=4 
a=.5
t=-z 
tStep=0.1
cur=curve(color=color.blue)
while theta<=(2*math.pi):
 x=c*(math.cosh(z/c))*math.cos(theta)
 y=c*(math.cosh(z/c))*math.sin(theta)
 curve.append(pos=(x,y,z))
 while t<=z:
    cur.append(pos=(t,a*math.cosh(t/a),0))
    t +=tStep
theta += thStep

Your issue is with this line: 您的问题是与此行:

curve=curve(color=color.green)

You are assigning curve to something else and thus, it no longer points to the function. 您正在将curve分配给其他对象,因此,它不再指向该函数。 When you use curve again, you are referencing the value you assigned to it, which is not a function and so, not callable. 再次使用curve时,将引用分配给它的值,该值不是函数,因此不可调用。

To help fix this issue, you should use a separate name for the variable. 为了帮助解决此问题,应为变量使用单独的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM