BJ Swope wrote: > On Jan 8, 2008 6:03 AM, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > >> BJ Swope wrote: >> >> > given a list such as >> > >> > ['messages', 'recipients', 'viruses'] >> > >> > how would I iterate over the list and use the values as variables and >> > open the variable names a files? >> > >> > I tried >> > >> > for outfile in ['messages', 'recipients', 'viruses']: >> > filename = os.path.join(Host_Path, outfile) >> > outfile = open(filename, 'w')
files = dict() l = ['messages', 'recipients', 'viruses'] for f in l: files[f] = open(s.path.join(Host_Path, outfile), "w") files["messages].write("a string") hth martin PS: Code is untested -- http://noneisyours.marcher.name http://feeds.feedburner.com/NoneIsYours You are not free to read this message, by doing so, you have violated my licence and are required to urinate publicly. Thank you. -- http://mail.python.org/mailman/listinfo/python-list