Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #47238
| References | <854fde32-9a5a-483e-b135-5d2c0d21b49b@googlegroups.com> <51B07D29.404@davea.name> <CAPTjJmqRpif0qo0Emkp7fZqOnaMtY5-JHj=tVnvNJAo1NPsobg@mail.gmail.com> <51B0B0A5.4050707@mrabarnett.plus.com> |
|---|---|
| Date | 2013-06-07 01:56 +1000 |
| Subject | Re: How to store a variable when a script is executing for next time execution? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2812.1370534214.3114.python-list@python.org> (permalink) |
On Fri, Jun 7, 2013 at 1:54 AM, MRAB <python@mrabarnett.plus.com> wrote:
> On 06/06/2013 16:37, Chris Angelico wrote:
>>
>> On Thu, Jun 6, 2013 at 10:14 PM, Dave Angel <davea@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.
Which is also a stated assumption of the binary search. The only
additional assumption of the file-count method is that there be no
other files in that directory.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
How to store a variable when a script is executing for next time execution? Avnesh Shakya <avnesh.nitk@gmail.com> - 2013-06-06 03:50 -0700 Re: How to store a variable when a script is executing for next time execution? Cameron Simpson <cs@zip.com.au> - 2013-06-06 21:19 +1000 Re: How to store a variable when a script is executing for next time execution? Avnesh Shakya <avnesh.nitk@gmail.com> - 2013-06-06 17:36 +0530 Re: How to store a variable when a script is executing for next time execution? Dave Angel <davea@davea.name> - 2013-06-06 08:14 -0400 Re: How to store a variable when a script is executing for next time execution? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-06-06 15:46 +0300 Re: How to store a variable when a script is executing for next time execution? Chris Angelico <rosuav@gmail.com> - 2013-06-07 01:37 +1000 Re: How to store a variable when a script is executing for next time execution? MRAB <python@mrabarnett.plus.com> - 2013-06-06 16:54 +0100 Re: How to store a variable when a script is executing for next time execution? Chris Angelico <rosuav@gmail.com> - 2013-06-07 01:56 +1000
csiph-web