関数があるとします
def equals_to(x,y):
a + b = c
def some_function(something):
for i in something:
...
このようなパラメータとしてc計算された使用方法はありますかequals_tosome_function
equals_to(1,2)
some_function(c)
return関数からの値にする必要がありcます。
def equals_to(x,y):
c = x + y # c = x + y not a + b = c
return c # return the value of c
def some_function(something):
for i in something:
...
return
sum = equals_to(1,2) # set sum to the return value from the function
some_function(sum) # pass sum to some_function
また、の関数シグネチャはequals_to引数を取りますx,yが、使用する関数でa,b割り当てが間違った方法でc行われた場合、の値は等しくありx + yません。a + bc
強くお勧めします:http://docs.python.org/2/tutorial/