2008/11/7 Ertl, John C CIV 63134 <[EMAIL PROTECTED]>:
> The idea is as I step through a list I want to use a different function
> (same name but from a different module) for each element in the list. How
> do I have a generic way to do this.
>
> for example for point 1 I want to use the rain function from Module A and
> then for point 2 I want to use the rain function from Module B.
Hi John,
You could use a dictionary to store the functions. For example:
import module_a
import module_b
rain_functions = { 1:module_a.get_rain, 2:module_b.get_rain }
Then you could call the function as:
x = forecast()
points = x.getPoints()
for point in points:
rain_functions[point]()
Hope this helps,
--
John.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor