[Tutor] Issue with iterating within lists, objects and functions

Andy Cheesman Andy.cheesman at bristol.ac.uk
Fri Aug 3 11:35:11 CEST 2007


Dear people,

Sorry for the vague title, I'm struggling to define the problem but an
example will be better/clearer.
If I've a list of strings, which relate to objects(lists) elsewhere in
my code, I can call list action fine within the loop but I was wondering
how do I apply an external function as shown below?

e.g

for thing in ["top", "right", "bottom", "left"]:
	eval("self." + thing).append("fish")
	eval("self." + thing +"_extra")
	eval("self." + thing) = external_function(eval("self." + thing)) #This
falls

Thanks for your help

Andy


More information about the Tutor mailing list