Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.026 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'slow.': 0.09; 'subject:script': 0.09; 'try:': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'ioerror:': 0.16; 'possible?': 0.16; 'simpson': 0.16; 'subject:variable': 0.16; 'subject:when': 0.16; 'survive': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'trying': 0.19; 'skip:f 30': 0.19; 'thu,': 0.19; 'thanks.': 0.20; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'script': 0.25; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'names.': 0.31; 'subject:next': 0.31; 'file': 0.32; 'run': 0.32; 'open': 0.33; 'url:python': 0.33; 'running': 0.33; 'subject:time': 0.33; 'could': 0.34; 'created': 0.35; 'except': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'var': 0.36; 'url:listinfo': 0.36; 'next': 0.36; 'subject:?': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'should': 0.36; 'skip:& 10': 0.38; 'audio': 0.38; 'files': 0.38; 'pm,': 0.38; 'enough': 0.39; 'according': 0.40; 'url:mail': 0.40; 'how': 0.40; 'read': 0.60; 'free': 0.61; 'break': 0.61; 'skip:o 30': 0.61; 'new': 0.61; 'save': 0.62; 'name': 0.63; 'pick': 0.64; 'more': 0.64; 'url:jsp': 0.68; 'played': 0.84; 'players.': 0.84; '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 :cc:content-type; bh=3EAMGiJcvb0oAgEDtjeoD3Owep44UM9jISMTYq3qjV4=; b=bAQVIsdX3urYBaXWixvMgUe8m3ODXoGbHDUlibQy6EtI//28shb2Ev+MfAKRRzbCHL o1Rz/hpOsql022KllXxtWoN7QLWqgykYFvLbWhDr1bVGDU6qAA/YHoSXQUafNk2wvFrj DoVeMwRbhppuBHTn58YE6XVsPrkrreWpDkFskLiqTnIOAcbFhs2fn15KuBn0wbo2WpZZ us/0MH78TPP0D6y1zS8lbjPpHBCu1e9RuiHVpb3TKMcZ61mug8j4mfN9nDDlEPEN2uwB kS3fjH7kZ1GpuA3XFRyYqeXL9UQ/MGFG1hJ9YFAJMP8l5rnBGQr+XfWniBgI1G6fLx0V 9bJw== MIME-Version: 1.0 X-Received: by 10.42.250.202 with SMTP id mp10mr16760808icb.21.1370520382220; Thu, 06 Jun 2013 05:06:22 -0700 (PDT) In-Reply-To: <20130606111904.GA29595@cskk.homeip.net> References: <854fde32-9a5a-483e-b135-5d2c0d21b49b@googlegroups.com> <20130606111904.GA29595@cskk.homeip.net> Date: Thu, 6 Jun 2013 17:36:22 +0530 Subject: Re: How to store a variable when a script is executing for next time execution? From: Avnesh Shakya To: Cameron Simpson Content-Type: multipart/alternative; boundary=20cf3010e6c98a328204de7b24ee Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 116 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370520389 news.xs4all.nl 15968 [2001:888:2000:d::a6]:45259 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47221 --20cf3010e6c98a328204de7b24ee Content-Type: text/plain; charset=ISO-8859-1 Thanks. On Thu, Jun 6, 2013 at 4:49 PM, Cameron Simpson wrote: > On 06Jun2013 03:50, Avnesh Shakya wrote: > | hi, > | I am running a python script and it will create a file name like > filename0.0.0 and If I run it again then new file will create one more like > filename0.0.1...... my code is- > | > | i = 0 > | for i in range(1000): > | try: > | with open('filename%d.%d.%d.json'%(0,0,i,)): pass > | continue > | except IOError: > | dataFile = file('filename%d.%d.%d.json'%(0,0,i,), 'a+') > | break > | But It will take more time after creating many files, So i want to store > value of last var "i" in a variable so that when i run my script again then > I can use it. for example- > | my last created file is filename0.0.27 then it should > store 27 in a variable and when i run again then new file should be created > 0.0.28 according to last value "27", so that i could save time and it can > create file fast.. > | > | Please give me suggestion for it.. How is it possible? > > Write it to a file? Read the file next time the script runs? > > BTW, trying to open zillions of files is slow. > But using listdir to read the directory you can see all the names. > Pick the next free one (and then test anyway). > -- > Cameron Simpson > > The mark must be robust enough to survive MP3 transmission over the > Internet, > but remain inaudible when played on the yet to be launched DVD-Audio > players. > - the SDMI audio watermarkers literally ask for the impossible, since all > audio compressors aim to pass _only_ human perceptible data > http://www.newscientist.com/news/news.jsp?id=ns224836 > -- > http://mail.python.org/mailman/listinfo/python-list > --20cf3010e6c98a328204de7b24ee Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Thanks.


On Thu, Jun 6, 2013 at 4:49 PM, Cameron Simpson <cs@zip.c= om.au> wrote:
On 0= 6Jun2013 03:50, Avnesh Shakya <= avnesh.nitk@gmail.com> wrote:
| hi,
| =A0 =A0I am running a python script and it will create a file name like f= ilename0.0.0 and If I run it again then new file will create one more like = filename0.0.1...... my code is-
|
| i =3D 0
| for i in range(1000):
| =A0 =A0 try:
| =A0 =A0 =A0 =A0 with open('filename%d.%d.%d.json'%(0,0,i,)): pass=
| =A0 =A0 =A0 =A0 continue
| =A0 =A0 except IOError:
| =A0 =A0 =A0 =A0 dataFile =3D file('filename%d.%d.%d.json'%(0,0,i,= ), 'a+')
| =A0 =A0 =A0 =A0 break
| But It will take more time after creating many files, So i want to store = value of last var "i" in a variable so that when i run my script = again then I can use it. for example-
| =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0my last created file is filename0.0.27= then it should store 27 in a variable and when i run again then new file s= hould be created 0.0.28 according to last value "27", so that i c= ould save time and it can create file fast..
|
| Please give me suggestion for it.. How is it possible?

Write it to a file? Read the file next time the script runs?
BTW, trying to open zillions of files is slow.
But using listdir to read the directory you can see all the names.
Pick the next free one (and then test anyway).
--
Cameron Simpson <cs@zip.com.au><= br>
The mark must be robust enough to survive MP3 transmission over the Interne= t,
but remain inaudible when played on the yet to be launched DVD-Audio player= s.
- the SDMI audio watermarkers literally ask for the impossible, since all =A0 audio compressors aim to pass _only_ human perceptible data
=A0 http://www.newscientist.com/news/news.jsp?id=3Dns224836<= br> --
http://mail.python.org/mailman/listinfo/python-list

--20cf3010e6c98a328204de7b24ee--