<div dir="ltr"><div>Hi,<br><br></div><div>If you want to have one program running forever and printing sales_records, you would do (one of the possibilities) something like this:<br>def salesrecord(serial_number):<br><br>    for i in salesrecord:<br>
        print first_sales_record<br>        serial_number += 1<br>        print serial_number<br>    return serial_number<br><br>if __name__ == '__main__':<br>    serial_number = 1<br><br>    # 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)<br></div><div><br></div><div>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.<br>
<br></div>Vytas<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 28, 2013 at 4:31 PM, Morten Engvoldsen <span dir="ltr"><<a href="mailto:mortenengv@gmail.com" target="_blank">mortenengv@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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>
<br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br></div>