Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to transmit a parameter to a function called in an other function ?

Here are 2 functions: the second call the first but obviously it doesn't transmit the value of sw to the first and I have an error of execution. So how should I do to obtain that swbe transmitted to pos_rat(x,y,sw) by ratio_for_pivot(x,y,sw)

 def pos_rat(x,y,sw) :
    if y>0:
        return x/y
    else :
        if sw == 1:
            return "-"
        elif sw == 2 :
            return -100000
def ratio_for_pivot(mat, var_ent, sw):
    return [pos_rat(mat[i][mat.ncols()-1],mat[i][var_ent],sw) for i in range(mat.nrows()-1)]

How to transmit a parameter to a function called in an other function ?

Here are 2 functions: the second call one calls the first one but obviously it doesn't doesn't transmit the value of sw to the first and I have an error of execution. execution. So how should I do to obtain that sw be transmitted to pos_rat(x,y,sw) pos_rat(x, y, sw) by ratio_for_pivot(x,y,sw)ratio_for_pivot(x, y, sw)?

 def pos_rat(x,y,sw) :
pos_rat(x, y, sw):
    if y>0:
y > 0:
        return x/y
    else :
else:
        if sw == 1:
            return "-"
        elif sw == 2 :
2:
            return -100000
 def ratio_for_pivot(mat, var_ent, sw):
    return [pos_rat(mat[i][mat.ncols()-1],mat[i][var_ent],sw) [pos_rat(mat[i][mat.ncols() - 1], mat[i][var_ent], sw)
            for i in range(mat.nrows()-1)]
range(mat.nrows() - 1)]

How to transmit a parameter to a function called in an other function ?

Here are 2 functions: the second one calls the first one but obviously it doesn't transmit the value of sw to the first and I have an error of execution. So how should I do to obtain that sw be transmitted to pos_rat(x, y, sw) by ratio_for_pivot(x, y, sw)?

 def pos_rat(x, y, sw):
    if y > 0:
        return x/y
    else:
        if sw == 1:
            return "-"
        elif sw == 2:
            return -100000

def ratio_for_pivot(mat, var_ent, sw):
    return [pos_rat(mat[i][mat.ncols() - 1], mat[i][var_ent], sw)
            for i in range(mat.nrows() - 1)]