Open a List of Files
paul.hankin at gmail.com
Wed Jan 9 11:29:14 CET 2008
On Jan 9, 10:02 am, Fredrik Lundh <fred... at pythonware.com> wrote:
> Paul Hankin wrote:
> > This can be more cleanly written using locals()
> > for fn in filenames:
> > locals()[fn] = open(os.path.join(host_path, fname + '.txt', 'wb')
> from the reference manual:
> Update and return a dictionary representing the current
> local symbol table.
> Warning: The contents of this dictionary should not be
> modified; changes may not affect the values of local
> variables used by the interpreter.
Thanks Fredrik! I learnt something today.
I wonder if there's a reason why it doesn't raise an exception when
you try to write to it? That would seem better to me than having it
sometimes update variables and sometimes not.
More information about the Python-list