Issue with continous incrementing of unbroken sequence for a entire working day

Rick Johnson rantingrickjohnson at gmail.com
Thu Feb 28 22:07:04 CET 2013


On Thursday, February 28, 2013 2:41:30 PM UTC-6, Morten Engvoldsen wrote:
>
> [...]
>
> def salesrecord():
>     serial_number = 0
>     sales_recrod = {'record1':'product1',
>                     'record2':'product2',
>                     'record3':'product3',
>                     }
> 
>     for i in sales_recrod:
>         print sales_recrod[i]
>         serial_number += 1
>     print serial_number
>     fo = open("workfile.txt", "wb")
>     fo.write(str(serial_number))
>     fo.close()
> 
>     with open("workfile.txt", 'r') as f:
>         serial_number = f.read()
>     today = date.today()


I would highly suggest breaking this code into a few specific functions:

def main()
def readDataFile()
def writeDataFile()
def computeDates()
def processSalesRecord()

and then run main from this:

if __name__ == '__main__':
    main()

PS: Please trim superfluous quotes.



More information about the Python-list mailing list