Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'elif': 0.05; 'output': 0.05; '#if': 0.07; 'sys': 0.07; 'assuming': 0.09; 'formatting': 0.09; 'friday,': 0.09; 'issue:': 0.09; 'none)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'trailing': 0.09; 'try:': 0.09; 'python': 0.11; 'def': 0.12; 'posted': 0.15; '"%s"': 0.16; '#elif': 0.16; '.txt': 0.16; '1:09': 0.16; 'dict': 0.16; 'doesnt': 0.16; 'epoch': 0.16; 'imports': 0.16; 'key/value': 0.16; 'keys:': 0.16; 'logger': 0.16; 'pairs': 0.16; 'range.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'storing': 0.16; 'strftime': 0.16; 'tab': 0.16; 'time.time()': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'subject:need': 0.19; '>>>': 0.22; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'earlier': 0.24; 'post': 0.26; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'program,': 0.31; 'code': 0.31; 'decimal': 0.31; 'file:': 0.31; 'keys': 0.31; 'pickle': 0.31; 'file': 0.32; 'thanks!': 0.32; 'run': 0.32; 'linux': 0.33; 'ago': 0.33; 'guess': 0.33; 'maybe': 0.34; 'subject:the': 0.34; 'subject:from': 0.34; 'december': 0.35; 'skip:s 30': 0.35; 'something': 0.35; 'but': 0.35; 'ubuntu': 0.36; 'should': 0.36; 'seconds': 0.37; 'unit': 0.37; 'list': 0.37; 'clear': 0.37; 'writes': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'skip:- 10': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'how': 0.40; 'commands': 0.60; 'number,': 0.60; 'new': 0.61; "you're": 0.61; 'email addr:gmail.com': 0.63; 'field': 0.63; 'here': 0.66; 'date,': 0.68; 'of:': 0.68; 'prompt': 0.68; 'smith': 0.68; 'article': 0.77; 'copy-paste': 0.84; 'fragment': 0.84; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Batchelder Subject: Re: need to print seconds from the epoch including the millisecond Date: Fri, 27 Dec 2013 13:49:54 -0500 References: <59aa73ac-e06e-4c0e-83a4-147ac42cad2e@googlegroups.com> <0c33b7e4-edc9-4e1e-b919-fec210c92d4a@googlegroups.com> <1db0d993-9d2d-46af-9ee8-69d9250dc803@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 18.189.30.229 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: <1db0d993-9d2d-46af-9ee8-69d9250dc803@googlegroups.com> 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: 125 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1388170207 news.xs4all.nl 2935 [2001:888:2000:d::a6]:40504 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62819 On 12/27/13 1:09 PM, matt.doolittle33@gmail.com wrote: > On Friday, December 27, 2013 11:27:58 AM UTC-5, Roy Smith wrote: >> In article <0c33b7e4-edc9-4e1e-b919-fec210c92d4a@googlegroups.com>, >> >> matt.doolittle33@gmail.com wrote: >> >> >> >>> I am on Ubuntu 12.10. I am still working with the 2 decimal places. >> >>> Sometime ago i had this issue and I forget how i solved it. maybe i used >> >>> datetime? thanks! >> >> >> >> That's strange. Linux should give you time to the microsecond, or >> >> something in that range. >> >> >> >> Please post the *exact* code you're running. The code you posted >> >> earlier is obviously only a fragment of some larger program, so we can >> >> only guess what's happening. Assuming your program is in a file called >> >> "prog.py", run the following commands and copy-paste the output: >> >> > i cant run it that way. i tried using the python prompt in terminal but got nothing. but here is all the code relevant to this issue: > #all the imports > import sys > import posixpath > import time > from time import strftime > from datetime import datetime > import os > import wx > import cPickle as pickle > import gnuradio.gr.gr_threading as _threading > > > #the function that writes the time values > def update(self, field_values): > > now = datetime.now() > > #logger --------------- > # new line to write on > self.logfile.write('\n') > # write date, time, and seconds from the epoch > self.logfile.write('%s\t'%(strftime("%Y-%m-%d",))) > self.logfile.write('%s\t'%(now.strftime("%H:%M:%S",))) > self.logfile.write('%s\t'%(time.time())) > # list to store dictionary keys in tis order > keys = ["duid", "nac", "tgid", "source", "algid", "kid"] > # loop through the keys in the right order > for k in keys: > # get the value of the current key > f = field_values.get(k, None) > # if data unit has value... > if f: > # output the value with trailing tab > self.logfile.write('%s\t'%(str(f))) > # if data unit doesnt have this value print a tab > else: > self.logfile.write('\t') > #end logger ---------------- > > #if the field 'duid' == 'hdu', then clear fields > if field_values['duid'] == 'hdu': > self.clear() > elif field_values['duid'] == 'ldu1': > self.clear() > elif field_values['duid'] == 'ldu2': > self.clear() > #elif field_values['duid'] == 'tdu': > # self.clear() > #loop through all TextCtrl fields storing the key/value pairs in k, v > for k,v in self.fields.items(): > # get the dict value for this TextCtrl > f = field_values.get(k, None) > # if the value is empty then set the new value > if f: > v.SetValue(f) > > #sample output in a .txt file: > > 2013-12-27 12:07:33 1388164053.18 > 2013-12-27 12:07:33 1388164053.36 > 2013-12-27 12:07:33 1388164053.54 > 2013-12-27 12:07:33 1388164053.73 > 2013-12-27 12:07:33 1388164053.91 > 2013-12-27 12:07:34 1388164054.11 > 2013-12-27 12:07:34 1388164054.28 > 2013-12-27 12:07:34 1388164054.48 > 2013-12-27 12:07:34 1388164054.66 > 2013-12-27 12:07:34 1388164054.84 > 2013-12-27 12:07:37 1388164057.62 > 2013-12-27 12:07:37 1388164057.81 > 2013-12-27 12:07:37 1388164057.99 > 2013-12-27 12:07:38 1388164058.18 > 2013-12-27 12:07:38 1388164058.37 > 2013-12-27 12:07:38 1388164058.54 > 2013-12-27 12:07:38 1388164058.73 > 2013-12-27 12:07:38 1388164058.92 > > Thanks! > Instead of: "%s" % time.time() try: "%.6f" % time.time() %.6f is a formatting code meaning, floating-point number, 6 decimal places. -- Ned Batchelder, http://nedbatchelder.com