Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62748 > unrolled thread
| Started by | matt.doolittle33@gmail.com |
|---|---|
| First post | 2013-12-26 10:32 -0800 |
| Last post | 2013-12-28 03:50 +0000 |
| Articles | 20 on this page of 37 — 14 participants |
Back to article view | Back to comp.lang.python
need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-26 10:32 -0800
Re: need to print seconds from the epoch including the millisecond Dan Stromberg <drsalists@gmail.com> - 2013-12-26 11:22 -0800
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-26 14:06 -0800
Re: need to print seconds from the epoch including the millisecond Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-27 09:34 +1100
Re: need to print seconds from the epoch including the millisecond Grant Edwards <invalid@invalid.invalid> - 2014-01-02 16:23 +0000
Re: need to print seconds from the epoch including the millisecond Dave Angel <davea@davea.name> - 2014-01-02 21:41 -0500
Re: need to print seconds from the epoch including the millisecond Grant Edwards <invalid@invalid.invalid> - 2014-01-03 15:33 +0000
Re: need to print seconds from the epoch including the millisecond Chris Angelico <rosuav@gmail.com> - 2014-01-04 02:41 +1100
Re: need to print seconds from the epoch including the millisecond Dave Angel <davea@davea.name> - 2013-12-26 17:48 -0500
Re: need to print seconds from the epoch including the millisecond Terry Reedy <tjreedy@udel.edu> - 2013-12-26 20:03 -0500
Re: need to print seconds from the epoch including the millisecond Roy Smith <roy@panix.com> - 2013-12-26 20:29 -0500
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-27 07:43 -0800
Re: need to print seconds from the epoch including the millisecond Dave Angel <davea@davea.name> - 2013-12-26 23:54 -0500
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-27 07:42 -0800
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-27 07:40 -0800
Re: need to print seconds from the epoch including the millisecond Dave Angel <davea@davea.name> - 2013-12-27 11:20 -0500
Re: need to print seconds from the epoch including the millisecond Roy Smith <roy@panix.com> - 2013-12-27 11:27 -0500
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-27 10:09 -0800
Re: need to print seconds from the epoch including the millisecond Roy Smith <roy@panix.com> - 2013-12-27 13:50 -0500
Re: need to print seconds from the epoch including the millisecond Roy Smith <roy@panix.com> - 2013-12-27 13:53 -0500
Re: need to print seconds from the epoch including the millisecond Roy Smith <roy@panix.com> - 2013-12-27 20:15 -0500
Re: need to print seconds from the epoch including the millisecond Ned Batchelder <ned@nedbatchelder.com> - 2013-12-27 13:49 -0500
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-30 04:16 -0800
Re: need to print seconds from the epoch including the millisecond Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-30 14:14 +0000
Re: need to print seconds from the epoch including the millisecond Cousin Stanley <cousinstanley@gmail.com> - 2013-12-30 10:07 -0700
Re: need to print seconds from the epoch including the millisecond Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-30 17:35 +0000
Re: need to print seconds from the epoch including the millisecond Cousin Stanley <cousinstanley@gmail.com> - 2013-12-30 11:17 -0700
Re: need to print seconds from the epoch including the millisecond Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-31 05:57 +1100
Re: need to print seconds from the epoch including the millisecond Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-27 13:14 -0500
Re: need to print seconds from the epoch including the millisecond Cameron Simpson <cs@zip.com.au> - 2013-12-28 11:25 +1100
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-29 18:44 -0800
Re: need to print seconds from the epoch including the millisecond Ned Batchelder <ned@nedbatchelder.com> - 2013-12-30 07:50 -0500
Re: need to print seconds from the epoch including the millisecond Roy Smith <roy@panix.com> - 2013-12-30 09:22 -0500
Re: need to print seconds from the epoch including the millisecond Ned Batchelder <ned@nedbatchelder.com> - 2013-12-30 08:01 -0500
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-30 05:40 -0800
Re: need to print seconds from the epoch including the millisecond Ned Batchelder <ned@nedbatchelder.com> - 2013-12-27 21:10 -0500
Re: need to print seconds from the epoch including the millisecond Steven D'Aprano <steve@pearwood.info> - 2013-12-28 03:50 +0000
Page 1 of 2 [1] 2 Next page →
| From | matt.doolittle33@gmail.com |
|---|---|
| Date | 2013-12-26 10:32 -0800 |
| Subject | need to print seconds from the epoch including the millisecond |
| Message-ID | <e0e7da6b-5cd9-4e6d-bcca-604bd4bd8d73@googlegroups.com> |
i am using 2.7. I need to print the time in seconds from the epoch with millisecond precision. i have tried many things but have failed. heres my latest:
from time import time, strftime
from datetime import datetime, time
# write date, time, then seconds from 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'%(now.time()))
what am i doing wrong? what should i be doing here? Thanks!
[toc] | [next] | [standalone]
| From | Dan Stromberg <drsalists@gmail.com> |
|---|---|
| Date | 2013-12-26 11:22 -0800 |
| Message-ID | <mailman.4638.1388085731.18130.python-list@python.org> |
| In reply to | #62748 |
On Thu, Dec 26, 2013 at 10:32 AM, <matt.doolittle33@gmail.com> wrote:
> i am using 2.7. I need to print the time in seconds from the epoch with millisecond precision. i have tried many things but have failed. heres my latest:
>
> from time import time, strftime
> from datetime import datetime, time
>
> # write date, time, then seconds from 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'%(now.time()))
In [1]: import time
In [2]: time.time()
Out[2]: 1388085670.1567955
HTH
[toc] | [prev] | [next] | [standalone]
| From | matt.doolittle33@gmail.com |
|---|---|
| Date | 2013-12-26 14:06 -0800 |
| Message-ID | <59aa73ac-e06e-4c0e-83a4-147ac42cad2e@googlegroups.com> |
| In reply to | #62749 |
On Thursday, December 26, 2013 2:22:10 PM UTC-5, Dan Stromberg wrote:
> On Thu, Dec 26, 2013 at 10:32 AM, <matt.doolittle33@gmail.com> wrote:
>
> > i am using 2.7. I need to print the time in seconds from the epoch with millisecond precision. i have tried many things but have failed. heres my latest:
>
> >
>
> > from time import time, strftime
>
> > from datetime import datetime, time
>
> >
>
> > # write date, time, then seconds from 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'%(now.time()))
>
>
>
> In [1]: import time
>
>
>
> In [2]: time.time()
>
> Out[2]: 1388085670.1567955
>
>
>
> HTH
OK i did what you said but I am only getting 2 decimal places.
Why is this and what can I do to get the millisecond?
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-12-27 09:34 +1100 |
| Message-ID | <52bcaeed$0$29995$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #62750 |
matt.doolittle33@gmail.com wrote: > On Thursday, December 26, 2013 2:22:10 PM UTC-5, Dan Stromberg wrote: >> On Thu, Dec 26, 2013 at 10:32 AM, <matt.doolittle33@gmail.com> wrote: >> >> > i am using 2.7. I need to print the time in seconds from the epoch >> > with millisecond precision. i have tried many things but have failed. [...] >> In [1]: import time >> In [2]: time.time() >> Out[2]: 1388085670.1567955 > > > OK i did what you said but I am only getting 2 decimal places. > Why is this and what can I do to get the millisecond? Please show *exactly* what you did. Also please tell us what operating system you are using. It may be that your operating system's clock doesn't provide millisecond precision. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2014-01-02 16:23 +0000 |
| Message-ID | <la43pq$isp$1@reader1.panix.com> |
| In reply to | #62751 |
On 2013-12-26, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote:
> matt.doolittle33@gmail.com wrote:
>
>> On Thursday, December 26, 2013 2:22:10 PM UTC-5, Dan Stromberg wrote:
>>> On Thu, Dec 26, 2013 at 10:32 AM, <matt.doolittle33@gmail.com> wrote:
>>>
>>> > i am using 2.7. I need to print the time in seconds from the epoch
>>> > with millisecond precision. i have tried many things but have failed.
> [...]
>>> In [1]: import time
>>> In [2]: time.time()
>>> Out[2]: 1388085670.1567955
>>
>>
>> OK i did what you said but I am only getting 2 decimal places.
>> Why is this and what can I do to get the millisecond?
>
> Please show *exactly* what you did. Also please tell us what operating
> system you are using. It may be that your operating system's clock doesn't
> provide millisecond precision.
AFAIK, that's irrelevent. time.time() returns a float. On all the
CPython implementations I know of, that is a 64-bit IEEE format, which
provides 16 decimal digits of precision regardless of the granularity
of the system time value. At this point in time, that means 10 digits
left of the decimal point and 6 to the right.
--
Grant Edwards grant.b.edwards Yow! Will the third world
at war keep "Bosom Buddies"
gmail.com off the air?
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2014-01-02 21:41 -0500 |
| Message-ID | <mailman.4820.1388716773.18130.python-list@python.org> |
| In reply to | #62977 |
On Thu, 2 Jan 2014 16:23:22 +0000 (UTC), Grant Edwards <invalid@invalid.invalid> wrote: > AFAIK, that's irrelevent. time.time() returns a float. On all the > CPython implementations I know of, that is a 64-bit IEEE format, which > provides 16 decimal digits of precision regardless of the granularity > of the system time value. At this point in time, that means 10 digits > left of the decimal point and 6 to the right. Correction: no more than about 6 to the right. You can certainly get less, from an os with a smaller resolution. Or you can lose some of what you do get by printing in a sub-optimal way. -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2014-01-03 15:33 +0000 |
| Message-ID | <la6l7u$nd0$1@reader1.panix.com> |
| In reply to | #63018 |
On 2014-01-03, Dave Angel <davea@davea.name> wrote:
> On Thu, 2 Jan 2014 16:23:22 +0000 (UTC), Grant Edwards
><invalid@invalid.invalid> wrote:
>> AFAIK, that's irrelevent. time.time() returns a float. On all the
>> CPython implementations I know of, that is a 64-bit IEEE format,
>> which provides 16 decimal digits of precision regardless of the
>> granularity of the system time value. At this point in time, that
>> means 10 digits left of the decimal point and 6 to the right.
>
> Correction: no more than about 6 to the right. You can certainly get
> less, from an os with a smaller resolution.
time.time() returns a Python float. A Python float will have 16 digits
of precision. Perhaps the OS always sets some of those digits to 0 (or
even random values), but they're still there. Perhaps the accuracy or
granularity of the values returned is problematic on some OSes, but
the precision of the value doesn't change: there's no way he's "only
getting 2 decimal places" from time.time() unless (as you mention
below) he's printing them using a method that truncates/rounds.
> Or you can lose some of what you do get by printing in a sub-optimal
> way.
Yes, depending on how you print the value, you can hide some of the
digits. But, there's no way for time.time() to return a value with
less than ~16 decimal digits of precicsion.
--
Grant Edwards grant.b.edwards Yow! ! Everybody out of
at the GENETIC POOL!
gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-01-04 02:41 +1100 |
| Message-ID | <mailman.4855.1388763675.18130.python-list@python.org> |
| In reply to | #63060 |
On Sat, Jan 4, 2014 at 2:33 AM, Grant Edwards <invalid@invalid.invalid> wrote:
> time.time() returns a Python float. A Python float will have 16 digits
> of precision. Perhaps the OS always sets some of those digits to 0 (or
> even random values), but they're still there. Perhaps the accuracy or
> granularity of the values returned is problematic on some OSes, but
> the precision of the value doesn't change: there's no way he's "only
> getting 2 decimal places" from time.time() unless (as you mention
> below) he's printing them using a method that truncates/rounds.
If I print out the value float("1.01"), I get just three digits. When
those trailing digits are all zeroes, they won't be displayed. That's
exactly what the OP was seeing.
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2013-12-26 17:48 -0500 |
| Message-ID | <mailman.4640.1388098035.18130.python-list@python.org> |
| In reply to | #62750 |
On Thu, 26 Dec 2013 14:06:17 -0800 (PST), matt.doolittle33@gmail.com wrote: > On Thursday, December 26, 2013 2:22:10 PM UTC-5, Dan Stromberg wrote: > > In [1]: import time > > In [2]: time.time() > > Out[2]: 1388085670.1567955 > OK i did what you said but I am only getting 2 decimal places. You're probably on Windows, which does time differently. Specify your os version and python version and somebody will probably know. -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2013-12-26 20:03 -0500 |
| Message-ID | <mailman.4642.1388106237.18130.python-list@python.org> |
| In reply to | #62750 |
On 12/26/2013 5:48 PM, Dave Angel wrote: > On Thu, 26 Dec 2013 14:06:17 -0800 (PST), matt.doolittle33@gmail.com wrote: >> On Thursday, December 26, 2013 2:22:10 PM UTC-5, Dan Stromberg > wrote: >> > In [1]: import time >> > In [2]: time.time() >> > Out[2]: 1388085670.1567955 > >> OK i did what you said but I am only getting 2 decimal places. > > You're probably on Windows, which does time differently. With 3.3 and 3.4 on Windows 7, time.time() gives 6 fractional digits. >>> import time; time.time() 1388105935.971099 > Specify your os version and python version and somebody will probably know. With 2.7, same machine, I only get 3. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2013-12-26 20:29 -0500 |
| Message-ID | <roy-B103F9.20291526122013@news.panix.com> |
| In reply to | #62750 |
In article <59aa73ac-e06e-4c0e-83a4-147ac42cad2e@googlegroups.com>, matt.doolittle33@gmail.com wrote: > > In [1]: import time > > In [2]: time.time() > > Out[2]: 1388085670.1567955 > > OK i did what you said but I am only getting 2 decimal places. > Why is this and what can I do to get the millisecond? What operating system are you on? The Python time routines can only return as much precision as the operating system makes available.
[toc] | [prev] | [next] | [standalone]
| From | matt.doolittle33@gmail.com |
|---|---|
| Date | 2013-12-27 07:43 -0800 |
| Message-ID | <d6c12175-2a89-4a9b-a9fa-b3a5eb4d6573@googlegroups.com> |
| In reply to | #62759 |
On Thursday, December 26, 2013 8:29:15 PM UTC-5, Roy Smith wrote: > In article <59aa73ac-e06e-4c0e-83a4-147ac42cad2e@googlegroups.com>, > > matt.doolittle33@gmail.com wrote: > > > > > > In [1]: import time > > > > In [2]: time.time() > > > > Out[2]: 1388085670.1567955 > > > > > > OK i did what you said but I am only getting 2 decimal places. > > > Why is this and what can I do to get the millisecond? > > > > What operating system are you on? The Python time routines can only > > return as much precision as the operating system makes available. I use Ubuntu 12.10. Thanks!
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2013-12-26 23:54 -0500 |
| Message-ID | <mailman.4650.1388120007.18130.python-list@python.org> |
| In reply to | #62750 |
On Thu, 26 Dec 2013 20:03:34 -0500, Terry Reedy <tjreedy@udel.edu> wrote: > On 12/26/2013 5:48 PM, Dave Angel wrote: > > You're probably on Windows, which does time differently. > With 3.3 and 3.4 on Windows 7, time.time() gives 6 fractional digits. > >>> import time; time.time() > 1388105935.971099 > With 2.7, same machine, I only get 3. The way I recall it, Windows time is a mess. To get better than 10 ms resolution you needed to use time.clock, but that isn't epoch time. Trickier solutions existed, depending on exactly what the problem was. But judging from your test, 3.3 built those gyrations into the stdlib. I dunno, I pretty much stopped using Windows 4 years ago. -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | matt.doolittle33@gmail.com |
|---|---|
| Date | 2013-12-27 07:42 -0800 |
| Message-ID | <bc30ed35-ad7e-4f41-94e6-4b2bbda99aa0@googlegroups.com> |
| In reply to | #62770 |
I pretty much stopped using Windows 4 > > years ago. > I got off the plantation over a year ago and have not looked back.
[toc] | [prev] | [next] | [standalone]
| From | matt.doolittle33@gmail.com |
|---|---|
| Date | 2013-12-27 07:40 -0800 |
| Message-ID | <0c33b7e4-edc9-4e1e-b919-fec210c92d4a@googlegroups.com> |
| In reply to | #62770 |
On Thursday, December 26, 2013 11:54:41 PM UTC-5, Dave Angel wrote: > On Thu, 26 Dec 2013 20:03:34 -0500, Terry Reedy <tjreedy@udel.edu> > > wrote: > > > On 12/26/2013 5:48 PM, Dave Angel wrote: > > > > You're probably on Windows, which does time differently. > > > > > With 3.3 and 3.4 on Windows 7, time.time() gives 6 fractional > > digits. > > > >>> import time; time.time() > > > 1388105935.971099 > > > > > With 2.7, same machine, I only get 3. > > > > The way I recall it, Windows time is a mess. To get better than 10 > > ms resolution you needed to use time.clock, but that isn't epoch > > time. Trickier solutions existed, depending on exactly what the > > problem was. But judging from your test, 3.3 built those gyrations > > into the stdlib. I dunno, I pretty much stopped using Windows 4 > > years ago. > > > > -- > > DaveA 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!
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2013-12-27 11:20 -0500 |
| Message-ID | <mailman.4669.1388161164.18130.python-list@python.org> |
| In reply to | #62804 |
On Fri, 27 Dec 2013 07:40:29 -0800 (PST), 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! Now I'm stumped. 2.7.3 on Ubuntu 12.04 and time.time gives me 6 decimals. Of course it's a float, so you could get more or fewer. But if you're only seeing 2, something else is different. -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2013-12-27 11:27 -0500 |
| Message-ID | <roy-CC46A3.11275827122013@news.panix.com> |
| In reply to | #62804 |
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: cat /etc/lsb-release uname -a python --version cat prog.py python prog.py
[toc] | [prev] | [next] | [standalone]
| From | matt.doolittle33@gmail.com |
|---|---|
| Date | 2013-12-27 10:09 -0800 |
| Message-ID | <1db0d993-9d2d-46af-9ee8-69d9250dc803@googlegroups.com> |
| In reply to | #62807 |
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!
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2013-12-27 13:50 -0500 |
| Message-ID | <roy-4A275D.13503227122013@news.panix.com> |
| In reply to | #62816 |
In article <1db0d993-9d2d-46af-9ee8-69d9250dc803@googlegroups.com>,
matt.doolittle33@gmail.com wrote:
> > 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.
Why can't you run it that way? What does "got nothing" mean? Did you
just get another shell prompt back with no output? Did your shell
window close? Did the machine crash?
I asked you to run these commands:
> cat /etc/lsb-release
>
> uname -a
>
> python --version
Did you run them? What output did you get? I know it seems silly, but
it really is important that people know exactly what your environment
is. The less information we have, the harder it is to figure out what's
going on.
> but here is all the code relevant to this issue:
Well, you've got a lot of code there. What you want to do is reduce
this down to the smallest possible amount of code which demonstrates the
problem.
I can't even begin to run your code here because I don't have gnuradio
installed. It's almost certainly not necessary to demonstrate the
problem (nor are posixpath, cPickle, wx, etc), but I can already see
that as soon as I delete those, I'll run up against the next problem,
which is that update() is a method of a class and I don't have the rest
of that class.
Let's take this one step at a time. You've got:
self.logfile.write('%s\t'%(time.time()))
which is apparently causing, "1388164053.18", to end up in your output
file. The question is, why are there only two digits after the decimal
place? Possible causes:
1) Your version of time.time() is returning a float which is only
precise to the centisecond.
2) Your version of string's %s operator is only converting floats to two
decimal places.
3) Your self.logfile.write() method is taking the string it was given
and stripping off all the digits beyond two after the decimal point.
All of those seem about equally unlikely, so just start to eliminate
them one by one. What happens if you do:
self.logfile.write("1388164053.183454")
What happens if you do:
t = time.time()
self.logfile.write("str=%s, repr=%s", (str(t), repr(t)))
what happens if you get rid of the whole self.logfile.write() thing and
just use print? If you're working in some environment where stdout gets
redirected somewhere that you can't find, bypass stdout completely:
my_file = open("/tmp/foo", "w")
print >> my_file, time.time()
and then go look and see what got dropped into /tmp/foo.
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2013-12-27 13:53 -0500 |
| Message-ID | <roy-172BE8.13533327122013@news.panix.com> |
| In reply to | #62818 |
In article <roy-4A275D.13503227122013@news.panix.com>,
Roy Smith <roy@panix.com> wrote:
> self.logfile.write("str=%s, repr=%s", (str(t), repr(t)))
Ugh, make that:
> self.logfile.write("str=%s, repr=%s" % ((str(t), repr(t)))
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.python
csiph-web