set variable to looping index?

Martin mdekauwe at
Wed Jul 29 20:56:28 CEST 2009


I am trying to set the return value from a function to a name which I
grab from the for loop. I can't work out how I can do this without
using an if statement...

for f in var1_fn, var2_fn, var3_fn:
    if f.split('.')[0] == 'var1':
        var1 = call_some_function(f)

 Really I would like to remove the need for this if loop and I am sure
there is a simple way I am missing?

Many thanks


More information about the Python-list mailing list