나는 pyclipse를 사용하여 python을 사용하여 Python을 Eclipse로 실행하기가 쉽지 않다. 내가 실행하려고 코드는 여기에 이클립스 EE 파이썬 2.7.3을 사용하고 있습니다 :파이썬 프로그램을 실행하려고 할 때마다 Eclipse에서 왜 '앤트 빌드'를 요청합니까?
def evaluate_poly(poly, x):
sumPoly = 0
for i in range(0,len(poly)):
#calculate each term and add to sum.
sumPoly = sumPoly+(poly[i]*x**i)
return sumPoly
def compute_deriv(poly):
derivTerm =()
#create a new tuple by adding a new term each iteration, assign to derivTerm each time.
for i in range(0,len(poly)):
#i is the exponent, poly[i] is the coefficient,
#coefficient of the derivative is the product of the two.
derivTerm = derivTerm + (poly[i]*i,)
return derivTerm
def compute_root(poly, x_0, epsilon):
#define root to make code simpler.
root = evaluate_poly(poly,x_0)
iterations = 0
#until root (evaluate_poly) is within our error range of 0...
while (root > epsilon) or (root < -epsilon):
#...apply newton's method, calculate new root, and count iterations.
x_0 = (x_0 - ((root)/(evaluate_poly(compute_deriv(poly),x_0))))
root = evaluate_poly(poly,x_0)
iterations = iterations + 1
return (x_0,iterations)
print compute_root((4.0,3.0,2.0),0.1,0.0001)
때마다 나는이 일식 개미 빌드로 저를 묻는다 실행 해보십시오. 확인을 클릭해도 아무 일도 일어나지 않습니다. 이것은 함수 내에서 함수를 실행할 때만 발생합니다. 아주 기본적인 코드는 문제가 아닙니다. 무엇이 잘못되었으며 어떻게 해결할 수 있습니까?
이것은 이클립스 일반적인 두통, 그리고 코드를 표시 할 필요가이 문제를 일으키지 않는 것 없다 : 가장 좋은 방법은 코드의 바닥에 이것을 추가하는 것입니다. – smci