Hi,<br>Okey i have wrote the below program as you suggested:<br><br>import time<br>from datetime import date<br><br>def salesrecord():<br>    serial_number = 0<br>    sales_recrod = {'record1':'product1', 'record2':'product2','record3':'product3'}<br>
    for i in sales_recrod:<br>        print sales_recrod[i]<br>        serial_number += 1<br>    print serial_number<br>    fo = open("workfile.txt", "wb")<br>    fo.write(str(serial_number))<br>    fo.close()<br>
    with open("workfile.txt", 'r') as f:<br>        serial_number = f.read()<br>    today = date.today()<br>    <br>    <br><br>salesrecord()<br><br><br>Here i am bit confuse with where i should write the read file function to read the current serial number and date. also when i overwrite the file with current serial number, it will overwrite the date also with current date, in that case how will i  compare the date. Can you please show me in my example how can i achive this..<br>
<br><br>---------- Forwarded message ----------<br>From: Matt Jones <<a href="mailto:matt.walker.jones@gmail.com">matt.walker.jones@gmail.com</a>><br>To: "<a href="mailto:python-list@python.org">python-list@python.org</a>" <<a href="mailto:python-list@python.org">python-list@python.org</a>><br>
Cc: <br>Date: Thu, 28 Feb 2013 13:11:38 -0600<br>Subject: Re: Issue with continous incrementing of unbroken sequence for a entire working day<br><div dir="ltr"><div class="gmail_default" style="font-family:'courier new',monospace">
Store
 the day as well as the serial_number in your file.  If the day is the 
same as today's day, use the serial_number, if not, use 1.  At the end 
of you program write the current day and serial_number.</div>

</div><br clear="all"><div><b>Matt Jones</b></div>
<br><br>On Thu, Feb 28, 2013 at 1:00 PM, Morten Engvoldsen <span dir="ltr"><<a href="mailto:mortenengv@gmail.com" target="_blank">mortenengv@gmail.com</a>></span> wrote:<br>

<div>Hi,</div><div>thanks for youe suggestion. I think i will go for your second option:</div><div><div> </div><div># Runs this loop until killed<br>    while True<br>        <do some stuff: clean serial_number, if day changed, calculate salesrecord etc.><br>



<br>        serial_number = salesrecord(serial_number)</div><div> </div><div> </div></div>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. What condition can be good, so that next day when the batch runs, 
it will know it has to reset the value 1.  Also my batch will not 
automatcilly run whole day, this is user's decision how many times he 
wants to run the batch in a day. Can you elebrate more how can i do that
 ...<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Morten Engvoldsen</b> <span dir="ltr"><<a href="mailto:mortenengv@gmail.com">mortenengv@gmail.com</a>></span><br>
Date: Thu, Feb 28, 2013 at 5:31 PM<br>Subject: Issue with continous incrementing of unbroken sequence for a entire working day<br>To: <a href="mailto:python-list@python.org">python-list@python.org</a><br><br><br><div>Hi team,</div>
<div>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. </div>


<div> </div><div>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.<br>

<br>Now this could be sample code how the program can count the sequence for a batch:<br><br>def salesrecord():<br>    serial_number = 1<br>    for i in selesrecord:<br>        print first_sales_record<br>        serial_number += 1<br>

        print serial_number<br><br>salesrecord()<br><br>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.<br>

<br>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. <br></div>
</div><br>