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


Groups > comp.lang.python > #47233

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.033
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'algorithm': 0.04; 'binary': 0.07; '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; 'file.': 0.24; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'existence': 0.31; 'subject:next': 0.31; 'subject:time': 0.33; 'could': 0.34; 'received:google.com': 0.35; '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; 'equals': 0.68; '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=jsEznhBviFrQJSSZWKp5BFPb7pBm+IpSpQKMWN/+r/U=; b=Lw18iy0kbLyNYY91L56aO/MzPak8l6cgVpTiZbJYjCYPK9+F3ux6NYK5MB7gsJj/9t og4iFGuooyHSttKxEN22jF4+XNkz9XhwjQfD0v4118xC1Yns9cnFvTRBT2yyzF5xKUkv aCfJG1eGT0+3oJCtaHqXfcC1qVRN98N5xHw1hN05/kCnNrV90L88h46rX2Kl5mLKb40D fIkiufc3mjS3sXs6X7XbXuWa/6pd7rms/wJneRfNNwSZ64qYIkoRIVR8V4W46a/DSG7v w/GoeRO7LknBo0FRf7H6CHB93A2ADnfGS8vP40LV2JnsjbY+krTlHnGefz2woJ145Ufg UzfA==
MIME-Version 1.0
X-Received by 10.52.155.67 with SMTP id vu3mr19003069vdb.94.1370533036577; Thu, 06 Jun 2013 08:37:16 -0700 (PDT)
In-Reply-To <51B07D29.404@davea.name>
References <854fde32-9a5a-483e-b135-5d2c0d21b49b@googlegroups.com> <51B07D29.404@davea.name>
Date Fri, 7 Jun 2013 01:37:16 +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.2808.1370533038.3114.python-list@python.org> (permalink)
Lines 13
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1370533039 news.xs4all.nl 15903 [2001:888:2000:d::a6]:48169
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:47233

Show key headers only | View raw


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.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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