set variable to looping index?

Martin mdekauwe at gmail.com
Wed Jul 29 14:56:28 EDT 2009


Hi,

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)
	.
        .
        .
      etc

 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

Martin




More information about the Python-list mailing list