Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.87.MISMATCH!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'mrab': 0.05; 'sufficient': 0.05; '"w")': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; "'r')": 0.16; 'subject: \n ': 0.16; 'subject:entire': 0.16; 'wrote:': 0.17; 'skip:{ 20': 0.17; 'subject:Issue': 0.17; '+0000': 0.20; 'import': 0.21; "skip:' 40": 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; '----------': 0.26; 'checking': 0.27; 'message- id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'date:': 0.29; 'fri,': 0.30; 'suggestion': 0.32; 'print': 0.32; 'code:': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'sequence': 0.35; 'received:209.85': 0.35; 'subject:': 0.36; 'compare': 0.36; 'email addr:python.org': 0.36; 'subject:with': 0.36; 'skip:p 20': 0.36; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'from:': 0.38; 'skip:o 20': 0.38; 'forwarded': 0.38; 'think': 0.40; 'email name:python-list': 0.62; 'here': 0.65; 'date,': 0.65; 'subject:day': 0.66; 'day': 0.73; '2013': 0.84 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=9FDAPNNkVxR57ggfU11UYgxSU6WfICTI6bjmDKHeDgM=; b=NRLCiIzvOeQV/xT5e4bz/iXw3409A69KsryHFhtWTuMntXfRkvbGEr9ulHhlVJKC/d +/eP2niVUywx/7HXCueddr6tplL5iNCbTAF6XBQxdCFUOp/HXoOBPk2+TehlveWPOBBF 8uBxN5kjJhr8qrC6cs9MKrNpjRsMlJGMUt511FS0bcdLXMqUuznJcrOjXS1U4ixibmaH 1uExWG2ihqQob7guFbuYLnAafS01/G6UGJxVwR1P6wmZzadbBQaVsWi0pvXA6wRPf2vt ud1eKT5UQFK2WZ2Fy9+syU72tOsaKNhoAox7MHvbvqqqqSlcYsA8y0lh387Ga5/682jR 98lQ== MIME-Version: 1.0 X-Received: by 10.180.79.227 with SMTP id m3mr5013337wix.12.1362155480007; Fri, 01 Mar 2013 08:31:20 -0800 (PST) In-Reply-To: References: Date: Fri, 1 Mar 2013 17:31:19 +0100 Subject: Re: Issue with continous incrementing of unbroken sequence for a entire working day From: Morten Engvoldsen To: python@mrabarnett.plus.com Content-Type: text/plain; charset=ISO-8859-1 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: 63 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362155486 news.xs4all.nl 6892 [2001:888:2000:d::a6]:54934 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40271 Hi, Yes, i think checking only date is sufficient . here is my code: from datetime import date def read_data_file(): with open("workfile.txt", 'r') as f: for line in f.readlines(): read_data = line.split(' ') return read_data def write_data_file(data): fo = open("workfile.txt", "w") fo.write(str(data)) fo.close() def comput_date(read_date, now_time, read_serial): if read_date == now_time: read_serial = int(read_serial) return read_serial + 1 else: read_serial = 1 return read_serial def process_sales_record(): now_time = time.strftime("%d-%m-%y") readdata = read_data_file() if readdata: read_serial = readdata[0] read_date = readdata[1] copute_date = comput_date(read_date, now_time, read_serial) serial_number = copute_date print serial_number sales_recrod = {'record1':'product1', 'record2':'product2','record3':'product3'} for i in sales_recrod: print sales_recrod[i] serial_number += 1 print serial_number data = str(serial_number) + ' ' + now_time writedata = write_data_file(data) print readdata Can you give me suggestion how can i improve this code.... ---------- Forwarded message ---------- From: MRAB To: python-list@python.org Cc: Date: Fri, 01 Mar 2013 14:09:43 +0000 Subject: Re: Issue with continous incrementing of unbroken sequence for a entire working day On 2013-03-01 09:42, Morten Engvoldsen wrote: Hi, Thanks.. :) so simply i can use time.strftime("%d%-m-%y %H:%M") , and then i can compare the date.... I think you're only interested in the date, not the time of day: time.strftime("%d-%m-%y")