How to store a variable when a script is executing for next time execution?

Chris Angelico rosuav at gmail.com
Thu Jun 6 11:37:16 EDT 2013


On Thu, Jun 6, 2013 at 10:14 PM, Dave Angel <davea at davea.name> wrote:
> If you're planning on having the files densely populated (meaning no gaps in
> the numbering), then you could use a binary search to find the last one.
> Standard algorithm would converge with 10 existence checks if you have a
> limit of 1000 files.

Or, if you can dedicate a directory to those files, you could go even simpler:

dataFile = open('filename0.0.%d.json'%len(os.listdir()), 'w')

The number of files currently existing equals the number of the next file.

ChrisA



More information about the Python-list mailing list