Fredrik Lundh <[EMAIL PROTECTED]> writes:
> BJ Swope wrote:
>
>> the code looks ok. please define "not working".
>>
>> Yep, defining "not working" is always helpful! :)
>>
>> I want to have all 3 files open at the same time. I will write to
>> each of the files later in my script but just the last file is open
>> for writing.
>
> to keep more than one file open, you need more than one variable, or a
> variable that can hold more than one object.
>
> if the number of files may vary, put the file objects in a list.
Or in a dict:
open_files = {}
for fn in ['messages', 'recipients', 'viruses']:
open_files[fn] = open(getfilename(fn), 'w')
# open_files['messages'] is the open file 'messages' etc.
--
http://mail.python.org/mailman/listinfo/python-list