Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98412

Re: time module

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Newsgroups comp.lang.python
Subject Re: time module
Date 2015-11-07 19:19 -0500
Organization IISS Elusive Unicorn
Message-ID <mailman.114.1446941944.16136.python-list@python.org> (permalink)
References <K0u%x.70622$_R5.38436@fx07.am1>

Show all headers | View raw


On Sat, 07 Nov 2015 21:27:06 GMT, input/ldompeling@casema.nl declaimed the
following:

>hi,
>
>I like to have a function that prints time in seconds.
>I am looking for something for example that seconds count from zero.
>I search the internet for time module in python but could not found anathing usefull.
>

	Ambiguous requirement: any normal counter starts from zero... But what
"zero" represents may differ... Seconds since Jan 1 1970? Seconds since
midnight? Seconds since start of program?

>>> import time
>>> t0 = time.time()
>>> t0
1446941608.052
>>> t0 / 60.0
24115693.467533335
>>> t0 / 60.0 / 60.0
401928.22445888893
>>> t0 / 60.0 / 60.0 / 24.0
16747.009352453704
>>> t0 / 60.0 / 60.0 / 24.0 / 365.25
45.850812737724034
>>> 

	Almost 46 years worth of seconds.

>>> tStart = time.time()
>>> for x in range(10):
... 	time.sleep(x)
... 	print time.time() - tStart
... 	
36.5020000935
37.5040001869
39.5090000629
42.5099999905
46.5170001984
51.5190000534
57.5200002193
64.5210001469
72.5230000019
81.5230000019
>>> 

Okay, I'm not the fastest typist (35 seconds from tStart to finishing the
loop code)
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

time module input/ldompeling@casema.nl - 2015-11-07 21:27 +0000
  Re: time module Cameron Simpson <cs@zip.com.au> - 2015-11-08 08:47 +1100
  Re: time module Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-07 19:19 -0500
    Re: time module input/ldompeling@casema.nl - 2015-11-08 10:25 +0000
      Re: time module Marko Rauhamaa <marko@pacujo.net> - 2015-11-08 13:05 +0200

csiph-web