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

MRAB python at mrabarnett.plus.com
Thu Jun 6 11:54:13 EDT 2013


On 06/06/2013 16:37, Chris Angelico wrote:
> 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.
>
Assuming no gaps.



More information about the Python-list mailing list