On Thu, Aug 18, 2011 at 11:19 AM, noydb <[email protected]> wrote:
> I am being passed the list of strings. I have variables set up
> already pointing to files. I need to loop through each variable in
> the list and do things to the files. The list of strings will change
> each time, include up to 22 of the same strings each time.
If you have a mapping of strings to values, you should just go ahead
and store them in a dictionary. Then the lookup becomes simple:
def foo(list_of_strings):
mapping = {
"bar0": "/var/log/bar0.log",
"bar1": "/usr/local/bar/bar1.txt",
"bar2": "/home/joe/logs/bar2.log",
}
for item in list_of_strings:
filename = mapping[item]
do_something(filename)
(Untested)
--
Jerry
--
http://mail.python.org/mailman/listinfo/python-list