Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #47238

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

Path csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'algorithm': 0.04; 'mrab': 0.05; 'binary': 0.07; 'assuming': 0.09; 'subject:script': 0.09; 'subject:How': 0.10; "'w')": 0.16; '(meaning': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:variable': 0.16; 'subject:when': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'thu,': 0.19; '>>>': 0.22; 'directory.': 0.24; 'file.': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'existence': 0.31; 'search.': 0.31; 'subject:next': 0.31; 'fri,': 0.33; 'subject:time': 0.33; 'could': 0.34; 'received:google.com': 0.35; 'there': 0.35; 'next': 0.36; 'method': 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; 'equals': 0.68; 'stated': 0.69; 'limit': 0.70; 'angel': 0.91; 'gaps': 0.93; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=sVLh/2sGAbrHinP/j+UMyTRt9bcUilPE0cu21DKi3bE=; b=dBB0zgTf3pc8ut0CCcCESvr/l2R95M6kmc+LT6kRA5EgLTj2TffvsUNDLU61GB+vfa WWvOyawa4x9Hi+/MSZJz2jwvggiDzFlwJzv5p61M1LgVl/YKfigl9ydIzHNdieq62MwZ 1qK9XqpGPGS+vRBZ+ln0bRDMpq0uJspEY8rV+vLe0C8zCGYlfCZ31lT1dviNlB6LuiZu ibsFC1QlLntasLU0QqLBJ9VQoMnOQdTxOpkSkMw4VTUTips3x2UHIQoG0IdNHkzeh7MJ RTahutRG5ynHfwfzuvweTCe/4Qw+pIb8tZ0GnPzYiLKKK9XEzQuKneJ5CIkIyh4brdS+ UebQ==
MIME-Version 1.0
X-Received by 10.220.109.66 with SMTP id i2mr22244137vcp.51.1370534212163; Thu, 06 Jun 2013 08:56:52 -0700 (PDT)
In-Reply-To <51B0B0A5.4050707@mrabarnett.plus.com>
References <854fde32-9a5a-483e-b135-5d2c0d21b49b@googlegroups.com> <51B07D29.404@davea.name> <CAPTjJmqRpif0qo0Emkp7fZqOnaMtY5-JHj=tVnvNJAo1NPsobg@mail.gmail.com> <51B0B0A5.4050707@mrabarnett.plus.com>
Date Fri, 7 Jun 2013 01:56:52 +1000
Subject Re: How to store a variable when a script is executing for next time execution?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2812.1370534214.3114.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1370534214 news.xs4all.nl 16004 [2001:888:2000:d::a6]:39034
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:47238

Show key headers only | View raw


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 | NextPrevious in thread | Find similar | Unroll thread


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