Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62881
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'interpreter': 0.05; 'url:pipermail': 0.05; 'float': 0.07; 'string': 0.09; 'friday,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'themselves,': 0.09; 'truncated': 0.09; 'python': 0.11; 'thread': 0.14; '2.7.2': 0.16; '2.7.3': 0.16; 'guessing': 0.16; 'luckily,': 0.16; 'precision,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'repr()': 0.16; 'reproduce': 0.16; 'simpson': 0.16; 'str()': 0.16; 'time.time()': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'subject:need': 0.19; 'feb': 0.22; '>>>': 0.22; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'received:comcast.net': 0.24; 'decide': 0.24; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'points': 0.29; 'statement': 0.30; "i'm": 0.30; 'asked': 0.31; '>>>>': 0.31; 'decimal': 0.31; 'sep': 0.31; 'time;': 0.31; 'thanks!': 0.32; 'url:python': 0.33; 'running': 0.33; 'ago': 0.33; 'maybe': 0.34; 'subject:the': 0.34; 'subject:from': 0.34; 'december': 0.35; 'something': 0.35; 'objects': 0.35; 'right?': 0.36; 'ubuntu': 0.36; 'similar': 0.36; 'url:org': 0.36; 'two': 0.37; 'to:addr :python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'url:mail': 0.40; 'how': 0.40; 'days': 0.60; "you're": 0.61; 'you.': 0.62; 'email addr:gmail.com': 0.63; 'show': 0.63; 'places': 0.64; 'more': 0.64; 'different': 0.65; 'feeling': 0.68; 'confusing': 0.84; '2013,': 0.91; '2013': 0.98 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Ned Batchelder <ned@nedbatchelder.com> |
| Subject | Re: need to print seconds from the epoch including the millisecond |
| Date | Mon, 30 Dec 2013 07:50:40 -0500 |
| References | <0c33b7e4-edc9-4e1e-b919-fec210c92d4a@googlegroups.com> <mailman.4682.1388190359.18130.python-list@python.org> <a891e541-7764-4aa2-a614-a6bceecd953e@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 | c-50-133-228-126.hsd1.ma.comcast.net |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
| In-Reply-To | <a891e541-7764-4aa2-a614-a6bceecd953e@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 <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4714.1388407860.18130.python-list@python.org> (permalink) |
| Lines | 84 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1388407860 news.xs4all.nl 2864 [2001:888:2000:d::a6]:42534 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:62881 |
Show key headers only | View raw
On 12/29/13 9:44 PM, matt.doolittle33@gmail.com wrote:
> On Friday, December 27, 2013 7:25:42 PM UTC-5, Cameron Simpson wrote:
>> On 27Dec2013 07:40, matt.doolittle33@gmail.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!
>>
>>
>>
>> Repeatedly people have asked you to show your exact code. Still nothing.
>>
>>
>>
>> Here's a clue, from a Gentoo box running kernel 3.2.1-gentoo-r2:
>>
>>
>>
>> $ python
>>
>> Python 2.7.2 (default, Feb 9 2012, 18:40:46)
>>
>> [GCC 4.5.3] on linux2
>>
>> Type "help", "copyright", "credits" or "license" for more information.
>>
>> >>> import time; print time.time()
>>
>> 1388190100.44
>>
>> >>> import time; time.time()
>>
>> 1388190102.795531
>>
>> >>>
>>
>>
>>
>> Please show us _exactly_ what you're doing. I'm guessing that print
>>
>> is confusing you.
>>
>>
>>
> matt@matt-Inspiron-1525:~$ python
> Python 2.7.3 (default, Sep 26 2013, 16:38:10)
> [GCC 4.7.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import time; print time.time()
> 1388371148.39
>>>> import time; time.time()
> 1388371173.556624
>>>>
>
> i get the same result as you expect. so its got to be the write statement that is truncated the decimal places right?
>
Objects in Python have two different ways to produce a string of
themselves, known as the str() and the repr(). A float's str() includes
two decimal points of precision, its repr() includes as many as you'd
need to reproduce the float again. The print statement implicitly uses
the str(), the interactive interpreter uses the repr().
Luckily, you can decide how to format the float yourself:
>>> import time
>>> time.time()
1388407706.617985
>>> print time.time()
1388407709.21
>>> print "%.3f" % time.time()
1388407716.377
>>> print "%.4f" % time.time()
1388407726.1001
BTW, I said something very similar in this thread 2.5 days ago:
https://mail.python.org/pipermail/python-list/2013-December/663454.html
I get the feeling not all messages are flowing to all places.
--
Ned Batchelder, http://nedbatchelder.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web