Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40179
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-02-28 13:07 -0800 |
| References | <CAJ2vgs6zZpHC_p=SuE7QWf7NDvokMjmE1N-aEN3a6n_DXi2=aQ@mail.gmail.com> <mailman.2674.1362084092.2939.python-list@python.org> |
| Message-ID | <c7d68adb-9ece-476e-b2da-869fe13ea97f@googlegroups.com> (permalink) |
| Subject | Re: Issue with continous incrementing of unbroken sequence for a entire working day |
| From | Rick Johnson <rantingrickjohnson@gmail.com> |
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.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Fwd: Issue with continous incrementing of unbroken sequence for a entire working day Morten Engvoldsen <mortenengv@gmail.com> - 2013-02-28 21:41 +0100 Re: Issue with continous incrementing of unbroken sequence for a entire working day Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-28 13:07 -0800
csiph-web