Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!pnx.dk!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'definitions': 0.07; 'exist,': 0.07; 'exists,': 0.09; 'file,': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject: \n ': 0.16; 'subject:entire': 0.16; 'utc': 0.16; 'wrote:': 0.17; 'subject:Issue': 0.17; 'clock': 0.22; 'simpler': 0.22; 'runs': 0.22; 'header:In-Reply-To:1': 0.25; 'skip:" 20': 0.26; 'am,': 0.27; 'i.e.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'decide': 0.28; 'run': 0.28; 'record': 0.28; 'changed.': 0.29; 'writes:': 0.29; 'reset': 0.29; 'probably': 0.29; 'fri,': 0.30; 'file': 0.32; 'date.': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'next': 0.35; 'subject:with': 0.36; 'does': 0.37; 'previous': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'john': 0.60; 'save': 0.61; 'day.': 0.63; 'date,': 0.65; 'serial': 0.66; 'subject:day': 0.66; 'today': 0.67; '2013': 0.84; 'careful': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=7GPLWmkhCP0MqgYqQfFopvtmAr/QcSafVnKK+SACCUY=; b=nHnu7WLQ3BqAG+8tS+qkSIXRAzRKsxm9H6u1oBgUPNXVutYMm5uWtU0K1Aft62cpKu dipfZMMgpRRHSe3vhDNNObwMVtd9WXEzgRTbmq4u22aruYmS91adBG30INA85rLwi2gk C4jjxicv4bVoiBj1LcmdxMDdk61yBuy8WBd5PUOFb8BguLDfyOx5lryqrQkdGH4jF1A7 STAb521BETLKHxSVMB2qIoXHomgThUjxoi8CBKJsMXJABCLvhyHnPSuW50F5uHps36gH Rj2kbrgDSR5UFqqiAalNVwDIXtUTaEhDszwE5SFO03F1M+tk2FP8PE6jOYAaScjVdL8s Qt2A== MIME-Version: 1.0 X-Received: by 10.52.22.194 with SMTP id g2mr2715786vdf.91.1362084724346; Thu, 28 Feb 2013 12:52:04 -0800 (PST) In-Reply-To: References: Date: Fri, 1 Mar 2013 07:52:04 +1100 Subject: Re: Issue with continous incrementing of unbroken sequence for a entire working day From: Chris Angelico 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362084726 news.xs4all.nl 6928 [2001:888:2000:d::a6]:43140 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40177 On Fri, Mar 1, 2013 at 6:23 AM, John Gordon wrote: > In Morten Engvoldsen writes: > >> But, if i save the serial_ number value in file, then how will it decide >> to reset the serial number to '1' when the batch runs on next working day. > > Name the file so that it contains the date, i.e. "serial_numbers.2013-02-28". > > If the file exists, you know that the program has already run today and > you can read the file to obtain the previous serial number. > > If the file does not exist, you know the program has not yet run today > and you can start the serial number at 1. Probably overkill; simpler to have just one file and record the date. Just be careful of definitions - do you use the current date UTC or the current date local time? And be aware of what might happen if the local clock is changed. ChrisA