<div dir="ltr">Thanks.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 6, 2013 at 4:49 PM, Cameron Simpson <span dir="ltr"><<a href="mailto:cs@zip.com.au" target="_blank">cs@zip.com.au</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 06Jun2013 03:50, Avnesh Shakya <<a href="mailto:avnesh.nitk@gmail.com">avnesh.nitk@gmail.com</a>> wrote:<br>

| hi,<br>
|    I am running a python script and it will create a file name like filename0.0.0 and If I run it again then new file will create one more like filename0.0.1...... my code is-<br>
|<br>
| i = 0<br>
| for i in range(1000):<br>
|     try:<br>
|         with open('filename%d.%d.%d.json'%(0,0,i,)): pass<br>
|         continue<br>
|     except IOError:<br>
|         dataFile = file('filename%d.%d.%d.json'%(0,0,i,), 'a+')<br>
|         break<br>
| But It will take more time after creating many files, So i want to store value of last var "i" in a variable so that when i run my script again then I can use it. for example-<br>
|                  my last created file is filename0.0.27 then it should store 27 in a variable and when i run again then new file should be created 0.0.28 according to last value "27", so that i could save time and it can create file fast..<br>

|<br>
| Please give me suggestion for it.. How is it possible?<br>
<br>
</div></div>Write it to a file? Read the file next time the script runs?<br>
<br>
BTW, trying to open zillions of files is slow.<br>
But using listdir to read the directory you can see all the names.<br>
Pick the next free one (and then test anyway).<br>
<span class="HOEnZb"><font color="#888888">--<br>
Cameron Simpson <<a href="mailto:cs@zip.com.au">cs@zip.com.au</a>><br>
<br>
The mark must be robust enough to survive MP3 transmission over the Internet,<br>
but remain inaudible when played on the yet to be launched DVD-Audio players.<br>
- the SDMI audio watermarkers literally ask for the impossible, since all<br>
  audio compressors aim to pass _only_ human perceptible data<br>
  <a href="http://www.newscientist.com/news/news.jsp?id=ns224836" target="_blank">http://www.newscientist.com/news/news.jsp?id=ns224836</a><br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div>