Q:

Multiple input/output arguments for function in python

I wrote the following function to convert a value (col) with unit (ufrom) into another unit (uto):
def convert(row, col , ufrom, uto):
    convRow = convDF[(convDF.from == row[ufrom]) & (convDF.to == uto)]
    val = row[col] / convRow.factor
    return(val, uto)

convDF is a dataframe containing several units and their conversion factor. I call the function like this:
for idx, row in df.iterrows():
    if row.Unit!= 'MM':
        df.at[idx, ['Width', 'Unit']] = convert(row,'Width', 'Unit', 'MM')
        df.at[idx, ['Length', 'Unit']] = convert(row,'Length', 'Unit', 'MM')
        df.at[idx, ['Hight', 'Unit']] = convert(row,'Hight', 'Unit', 'MM')

The convert function gets the current row, the column containing the value that needs to be converted, the source unit column as well as the destination unit. So far it works perfectly.
As you can see, I call the function three times but I was wondering if I could call it once and pass all three arguments (Width, Length, Hight) and convert them because they have the same column refering to their unit (Unit) and the same destination unit (uto). So I would like the function to handle single as well as multiple values. 
In the end, this
df.at[idx, ['Width', 'Unit']] = convert(row,'Width', 'Unit', 'MM')

should work as well as this
df.at[idx, ['Width','Length','Hight', 'Unit']] = convert(row,['Width','Length','Hight'],'Unit', 'MM')

Tried working with the *-syntax for passing 1:n arguments but how do I change the convert function to give multiple or single results?
Thank you!

A:

You can have your function take a list of columns as an argument then return a list based on what is in the column list. For example, 
def convert(row, cols , ufrom, uto):
    values=[]
    for col in cols:
        convRow = convDF[(convDF.from == row[ufrom]) & (convDF.to == uto)]
        values.append(row[col] / convRow.factor) 
    values.append(ufrom) 
    return values

and then you could call it like
df.at[idx, ['Width','Length','Hight', 'Unit']] = convert(row,['Width','Length','Hight'],'Unit', 'MM')

or in the case of one column, just have a list with one element: 
df.at[idx, ['Width', 'Unit']] = convert(row,['Width'],'Unit', 'MM')

