Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'algorithm': 0.04; 'binary': 0.07; 'assuming': 0.09; 'subject:script': 0.09; 'subject:How': 0.10; "'w')": 0.16; '(meaning': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'subject: \n ': 0.16; 'subject:variable': 0.16; 'subject:when': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'header:User- Agent:1': 0.23; 'file.': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'existence': 0.31; 'subject:next': 0.31; 'subject:time': 0.33; 'could': 0.34; 'next': 0.36; 'subject:?': 0.36; 'checks': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'planning': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'dave': 0.60; "you're": 0.61; 'header:Reply-To:1': 0.67; 'equals': 0.68; 'limit': 0.70; 'reply-to:no real name:2**0': 0.71; 'reply-to:addr:python.org': 0.84; 'angel': 0.91; 'gaps': 0.93; '2013': 0.98 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=KrN0hwmN c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=oyR3mlnJdzkA:10 a=Akf1ylsSNtwA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=BMYZR9uYiSUA:10 a=ekxJSCFMZvBWJMiBkfkA:9 a=HxMiCoyDvHHk_rbR:21 a=dcSmYEvDEyhstYAK:21 a=wPNLvfGTeEIA:10 X-AUTH: mrabarnett:2500 Date: Thu, 06 Jun 2013 16:54:13 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: How to store a variable when a script is executing for next time execution? References: <854fde32-9a5a-483e-b135-5d2c0d21b49b@googlegroups.com> <51B07D29.404@davea.name> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370534054 news.xs4all.nl 15935 [2001:888:2000:d::a6]:35509 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47237 On 06/06/2013 16:37, Chris Angelico wrote: > On Thu, Jun 6, 2013 at 10:14 PM, Dave Angel 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.