Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.python
Re: Open a List of Files
Martin Marcher
1/8/2008 12:04:00 PM
BJ Swope wrote:
> On Jan 8, 2008 6:03 AM, Fredrik Lundh <fredrik@pythonware.com> 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.ma...
http://feeds.feedburner.com/N...
You are not free to read this message,
by doing so, you have violated my licence
and are required to urinate publicly. Thank you.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Open a List of Files
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password