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


Groups > comp.lang.python > #98404 > unrolled thread

time module

Started byinput/ldompeling@casema.nl
First post2015-11-07 21:27 +0000
Last post2015-11-08 13:05 +0200
Articles 5 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  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

#98404 — time module

Frominput/ldompeling@casema.nl
Date2015-11-07 21:27 +0000
Subjecttime module
Message-ID<K0u%x.70622$_R5.38436@fx07.am1>
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.

Has someone an example for it.

Thanks


-- 
--------------------------------- --- -- -
Posted with NewsLeecher v7.0 Beta 2
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -

[toc] | [next] | [standalone]


#98405

FromCameron Simpson <cs@zip.com.au>
Date2015-11-08 08:47 +1100
Message-ID<mailman.109.1446934443.16136.python-list@python.org>
In reply to#98404
On 07Nov2015 21:27, input/ldompeling@casema.nl <input/ldompeling@casema.nl> wrote:
>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.

Here:

  https://docs.python.org/3/library/time.html#time.time

Cheers,
Cameron Simpson <cs@zip.com.au>

[toc] | [prev] | [next] | [standalone]


#98412

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2015-11-07 19:19 -0500
Message-ID<mailman.114.1446941944.16136.python-list@python.org>
In reply to#98404
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/

[toc] | [prev] | [next] | [standalone]


#98435

Frominput/ldompeling@casema.nl
Date2015-11-08 10:25 +0000
Message-ID<sqF%x.23626$mP1.4332@fx24.ams1>
In reply to#98412
>  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?

Thanks for the reply

Yes, I would like seconds since start of program.
Can I not doing something like time()=0 only this gives an error.

Thanks
------------------------------------------------------------------------
In reply to "Dennis Lee Bieber" who wrote the following:

> 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/




-- 
--------------------------------- --- -- -
Posted with NewsLeecher v7.0 Beta 2
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -

[toc] | [prev] | [next] | [standalone]


#98439

FromMarko Rauhamaa <marko@pacujo.net>
Date2015-11-08 13:05 +0200
Message-ID<87vb9cwy3l.fsf@elektro.pacujo.net>
In reply to#98435
input/ldompeling@casema.nl:

> Yes, I would like seconds since start of program.
> Can I not doing something like time()=0 only this gives an error.

Here:

    class MyReckoning:
        def __init__(self):
            self.the_beginning = time.time()

        def time(self):
            return time.time() - self.the_beginning

    reckoning = MyReckoning()
    print(reckoning.time())


Marko

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web