Opening Multiple files at one time
davea at davea.name
Tue Apr 21 00:49:36 CEST 2015
On 04/20/2015 07:59 AM, subhabrata.banerji at gmail.com wrote:
> Dear Group,
> I am trying to open multiple files at one time.
> I am trying to do it as,
> for item in [ "one", "two", "three" ]:
> f = open (item + "world.txt", "w")
> This is fine.
But it does not open multiple files at one time. Perhaps you'd better
explain better what you mean by "at one time."
> But I was looking if I do not know the number of
> text files I would create beforehand,
So instead of using a literal list [ "one", "two... ]
you construct one, or read it in from disk, or use sys.argv. What's the
difficulty? Nothing in the code fragment you show cares how long the
so not trying xrange option
No idea what "the xrange option" means.
> And if in every run of the code if the name of the text files have
> to created on its own.
So figure out what you're going to use for those names, and write the
code to generate them.
> Is there a solution for this?
More information about the Python-list