Open a List of Files
Fredrik Lundh
fredrik at pythonware.com
Tue Jan 8 06:03:45 EST 2008
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')
>
> But it's not working.
the code looks ok. please define "not working".
</F>
More information about the Python-list
mailing list