how to call the python function by passing the output of the function as input to the function

Refresh

February 2019

Views

25 time

0

I need to write a python function call logic that calls the python function multiple times.

let's say for example I have a script test.py

I'm running the script like python test.py val

val=sys.argv[1]
def check(param, val):
    .
    .
    .
    if val == valid.text:
        print '{:10s}:{:10}'.format(param, all.text)

values=os.walk(runtime).next()[1]
for param in values:
    check(param, val)

so here the output like

driver                          1.1
dmname                          1.5-temp
fdrmenu                         1.0-rem

so here I need to run the same function check(param, val) by taking the output as input for the function call.

the function calls like check(param, val) --> here val should be driver and so on for dmname , fdrmenu.

and call same function for output of driver, dmname and so on until we get the null for all the outputs.

here sys.srgv[1] should assign to val only for the first time, from next time it should be driver, dmname and so on.

1 answers

0

Что-то рекурсивно, как это?

data={1:2,2:3,5:6} 
def check(data,key):
    val = data.pop(key)
    if type(val) == int:
        print(key,val)
        if data: check(data,list(data.keys())[0])
    return None

check(data,list(data.keys())[0])