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


February 2019


25 time


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

I'm running the script like python val

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

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


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

def check(data,key):
    val = data.pop(key)
    if type(val) == int:
        if data: check(data,list(data.keys())[0])
    return None