Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; '__name__': 0.07; '1000.': 0.09; 'filed': 0.09; 'record.': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; "'__main__':": 0.16; 'finishes': 0.16; 'increment': 0.16; 'subject: \n ': 0.16; 'subject:entire': 0.16; 'wrote:': 0.17; 'subject:Issue': 0.17; 'thu,': 0.17; 'team,': 0.18; 'feb': 0.19; 'email addr:gmail.com>': 0.20; 'python?': 0.20; '\xa0so': 0.22; 'runs': 0.22; 'cc:2**0': 0.23; 'this:': 0.23; 'cc:no real name:2**0': 0.24; 'second': 0.24; 'script': 0.24; 'pass': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'run': 0.28; 'url:mailman': 0.29; 'reset': 0.29; "skip:' 10": 0.30; 'saves': 0.30; 'code': 0.31; 'url:python': 0.32; 'file': 0.32; 'running': 0.32; 'could': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'received:74.125.82': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'sequence': 0.35; 'pm,': 0.35; 'continue': 0.35; 'something': 0.35; 'next': 0.35; 'received:74.125': 0.36; 'url:org': 0.36; 'subject:with': 0.36; 'should': 0.36; 'throughout': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'some': 0.38; 'url:mail': 0.40; 'your': 0.60; 'day,': 0.60; 'save': 0.61; 'first': 0.61; 'time,': 0.62; 'day.': 0.63; 'maximum': 0.63; 'series': 0.63; '10.': 0.64; 'serial': 0.66; 'subject:day': 0.66; 'records': 0.68; 'sales': 0.70; 'day': 0.73; '11.': 0.81; '2013': 0.84; 'stuff:': 0.84; 'day,\xa0': 0.91; 'killed': 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:cc:content-type; bh=wijtgAtbOSz13pVr43GRITP+i9hKa6an6AdCs2qwXi0=; b=mwpS1omA7DYdOGeeKXMSNATz9Cje73NTqu6n38LZMqB9ggse8iQSjnSkls3ZnhPriS g3I7wsdzUv0mmN896oqWeWoBjOWvzspx3KMfdHTQEOugcfXspQ6p3coY8RlIMzyKqDdx PSDywyQYVi2PTaWHPu1QoQpMG9OsOVO/I60S7hgyhYem3sjKse74Q0LC/nMaM04jWkpK C3R4hmpkPi3E3HBveNfmajYutM5lNr/dBSBzNpuluQJz+71JQ0SndO6F+UukW4h7hfex 7b+yiUvLNanyUHJ3SSMzm4dNGVx6ju47CfQ8BSi3AqORWLeiKJ3x9EKV6071qI3ZHTgo UTbg== MIME-Version: 1.0 X-Received: by 10.180.93.168 with SMTP id cv8mr12294464wib.5.1362073408649; Thu, 28 Feb 2013 09:43:28 -0800 (PST) In-Reply-To: References: Date: Thu, 28 Feb 2013 17:43:28 +0000 Subject: Re: Issue with continous incrementing of unbroken sequence for a entire working day From: "Vytas D." To: Morten Engvoldsen Content-Type: multipart/alternative; boundary=f46d043c7fbaae454b04d6cc6da4 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: 134 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362073410 news.xs4all.nl 6950 [2001:888:2000:d::a6]:44929 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40147 --f46d043c7fbaae454b04d6cc6da4 Content-Type: text/plain; charset=ISO-8859-1 Hi, If you want to have one program running forever and printing sales_records, you would do (one of the possibilities) something like this: def salesrecord(serial_number): for i in salesrecord: print first_sales_record serial_number += 1 print serial_number return serial_number if __name__ == '__main__': serial_number = 1 # Runs this loop until killed while True serial_number = salesrecord(serial_number) If you want to run your script so it finishes and then saves last value of serial_number, so you can pass it to your script when it runs next time, you should save the value to some file and read that file on every start of your program. Vytas On Thu, Feb 28, 2013 at 4:31 PM, Morten Engvoldsen wrote: > Hi team, > I need to run a batch of sales records and the batch has serial_number > filed to store the serial number of the sales record. The serial number > should be set to 1 everyday when the batch runs first time in a day and > the maximum serial number could be 1000. > > So when the batch runs first time in a day and if it has 10 records, so > the last serial number will be 10. And when the batch runs 2nd time in same > day, the serial number should start from 11. In this way serial_number > will increment as an unbroken series throughout the entire working day. The > next day when the batch runs first time the serial number will reset to 1. > > Now this could be sample code how the program can count the sequence for a > batch: > > def salesrecord(): > serial_number = 1 > for i in selesrecord: > print first_sales_record > serial_number += 1 > print serial_number > > salesrecord() > > So if the batch has 10 records and last serial number of first batch is > 10, then when the batch runs second time in the same day, how the > 'serial_number' will get the value of 10 and then continue the serial > number for the same day, then for next day again the serial number will > start from 1. > > Can you let me know how can i achive this in python? As i am in learning > phase of python, can you let me know what would be good approach to do this > in python. > > -- > http://mail.python.org/mailman/listinfo/python-list > > --f46d043c7fbaae454b04d6cc6da4 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi,

If you want to have one program= running forever and printing sales_records, you would do (one of the possi= bilities) something like this:
def salesrecord(serial_number):

= =A0=A0=A0 for i in salesrecord:
=A0=A0=A0=A0=A0=A0=A0 print first_sales_record
=A0=A0=A0=A0=A0=A0=A0 ser= ial_number +=3D 1
=A0=A0=A0=A0=A0=A0=A0 print serial_number
=A0=A0=A0= return serial_number

if __name__ =3D=3D '__main__':
=A0= =A0=A0 serial_number =3D 1

=A0=A0=A0 # Runs this loop until killed =A0=A0=A0 while True
=A0=A0=A0=A0=A0=A0=A0 <do some stuff: clean seri= al_number, if day changed, calculate salesrecord etc.>

=A0=A0=A0= =A0=A0=A0=A0 serial_number =3D salesrecord(serial_number)
If you want to run your script so it finishes and then saves la= st value of serial_number, so you can pass it to your script when it runs n= ext time, you should save the value to some file and read that file on ever= y start of your program.

Vytas


On Thu, Feb 28, 2013 at 4:31 PM, Morten Engvoldsen <mortene= ngv@gmail.com> wrote:
Hi team,
I need to run a batc= h=A0of sales records and =A0the batch has=A0serial_number filed to store th= e serial number of the sales record. The serial number should be set to=A0= =A01 everyday when the batch runs first time in a day and the maximum seria= l number could be 1000.
=A0
So when the batch runs first time in a day=A0and if it h= as 10 records, so the last serial number will be 10. And when the batch run= s 2nd time in same day, the serial number should start from 11.=A0 In this = way serial_number will increment as an unbroken series throughout the entir= e working day. The next day when the batch runs first time the serial numbe= r will reset to 1.

Now this could be sample code how the program can count the sequence fo= r a batch:

def salesrecord():
=A0=A0=A0 serial_number =3D 1
= =A0=A0=A0 for i in selesrecord:
=A0=A0=A0=A0=A0=A0=A0 print first_sales_= record
=A0=A0=A0=A0=A0=A0=A0 serial_number +=3D 1
=A0=A0=A0=A0=A0=A0=A0 print serial_number

salesrecord()

So if= the batch has 10 records and last serial number of first batch is 10, then= when the batch runs second time in the same day, how the 'serial_numbe= r' will get the value of 10 and then continue the serial number for the= same day,=A0 then for next day again the serial number will start from 1.<= br>
Can you let me know how can i achive this in python? As i am in learnin= g phase of python, can you let me know what would be good approach to do th= is in python.

--
http://mail.python.org/mailman/listinfo/python-list


--f46d043c7fbaae454b04d6cc6da4--