On Tue, Aug 26, 2014 at 09:56:55AM +0530, diliup gabadamudalige wrote:
> Hi all,
>
> 1. why do some say that the time module is more accurate than the timeit
> module?
> s = time.time()
> or
> s = timeit.timeit()
You will have to ask them.
Since the two functions do very different things, I don'
On Tue, Aug 26, 2014 at 6:26 AM, diliup gabadamudalige
wrote:
> Hi all,
>
> 1. why do some say that the time module is more accurate than the timeit
> module?
> s = time.time()
> or
> s = timeit.timeit()
>
> 2. Why is it that both modules never return the same answer on each run?
The two function
Hi all,
1. why do some say that the time module is more accurate than the timeit
module?
s = time.time()
or
s = timeit.timeit()
2. Why is it that both modules never return the same answer on each run?
Thank you for your response.
--
Diliup Gabadamudalige
http://www.diliupg.com
http://soft.dil
On 21/04/13 03:10, Jim Mooney wrote:
This is why we tend to recommend 2.7 for anyone doing serious work in
Python.
Understood. I am in no rush, but what do you think it the time frame
when Py 3 will be mature?
As Steven has already pointed out Python 3 itself is mature.
The problem i
On 21/04/13 12:10, Jim Mooney wrote:
This is why we tend to recommend 2.7 for anyone doing serious work in
Python.
Understood. I am in no rush, but what do you think it the time frame when
Py 3 will be mature? A year from now? Two years? At some point I might want
to use it more practically. O
> This is why we tend to recommend 2.7 for anyone doing serious work in
> Python.
>
Understood. I am in no rush, but what do you think it the time frame when
Py 3 will be mature? A year from now? Two years? At some point I might want
to use it more practically. Or maybe there will be huge inflatio
On Sat, Nov 12, 2011 at 6:07 AM, Cameron Macleod wrote:
> Hi,
>
> I've been trying to code a timer that tells you how long you've been on
> the net and I can't figure out how to produce a figure in hours, minutes
> and seconds that is constantly being updated. If anyone could point out a
> module
Hi,
I've been trying to code a timer that tells you how long you've been on the
net and I can't figure out how to produce a figure in hours, minutes and
seconds that is constantly being updated. If anyone could point out a
module with functions like this or built in functions, I'd be very grateful
Quick question - Is any daylight saving taken into consideration for this?
On Tue, Aug 2, 2011 at 1:35 AM, ian douglas wrote:
> Hi all,
>
> Been trying to wrap my head around some datetime vs time stuff with regards
> to parsing a string as a date plus time with a timezone offset.
>
> This is the
Hi all,
Been trying to wrap my head around some datetime vs time stuff with
regards to parsing a string as a date plus time with a timezone offset.
This is the string I'm given:
2010-01-22T00:14:33.000Z
And I can use time.strptime to parse out its individual elements, but
then I need to adj
tee chwee liong wrote:
hi,
i would like to know the time taken to execute a certain task in python. i used time.time and time.clock and i see the time taken is different? what is the right method to use?
Neither, or either. For timing small code snippets, the right tool is
the timeit module
u are effectively profiling a single if statement...
Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/
From: tee chwee liong
To: alan.ga...@btinternet.com; tutor@python.org
Sent: Thursday, 17 March, 2011 9:06:56
Subject: RE: [Tutor] time tak
hi,
i used profiler. but it gives 0 sec? is this expected? tq
>>> profile.run('import math')
3 function calls in 0.000 CPU seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
10.0000.0000.0000.000 :0(set
"tee chwee liong" wrote
i would like to know the time taken to execute a
certain task in python. i used time.time and time.clock
and i see the time taken is different?
what is the right method to use?
Neither of those, either use timeit() or the Python profiler.
They are both specifically
On 3/16/11, tee chwee liong wrote:
>
> hi,
>
> i would like to know the time taken to execute a certain task in python. i
> used time.time and time.clock and i see the time taken is different? what is
> the right method to use?
>
> import time
> def testtime(num):
> start=time.time()
> #pr
On Wed, Mar 16, 2011 at 9:40 PM, tee chwee liong wrote:
> hi,
>
> i would like to know the time taken to execute a certain task in python. i
> used time.time and time.clock and i see the time taken is different? what is
> the right method to use?
>
> import time
> def testtime(num):
> start=
hi,
i would like to know the time taken to execute a certain task in python. i used
time.time and time.clock and i see the time taken is different? what is the
right method to use?
import time
def testtime(num):
start=time.time()
#print start
for n in range(num):
#print
I have a module which measures elapsed time. It can also wait til a certain
amount of time has passed till ending. I can send it to you if you like.
On Thu, Jun 24, 2010 at 8:59 AM, Hugo Arts wrote:
> On Wed, Jun 23, 2010 at 3:11 AM, Dave Angel wrote:
> >
> > If you're really looking to measure
On Wed, Jun 23, 2010 at 3:11 AM, Dave Angel wrote:
>
> If you're really looking to measure performance, you should use the timeit
> module. But for simply deciding how much time has elapsed between two
> points in your code, you can use the time.time() function.
>
Another one I think is worth me
On Wed, 23 Jun 2010 11:11:32 am Dave Angel wrote:
> If you're really looking to measure performance, you should use the
> timeit module. But for simply deciding how much time has elapsed
> between two points in your code, you can use the time.time()
> function.
>
> import time
>
> start = time.ti
Ahmed AL-Masri wrote:
Hi,
I would calculate the running time of my simulation code.
any one know how to do that?
example
def demo():
### the starting point of time should be 0
f.simulate(data)
### the end of the class so need to find the time in Sec.?
#
Ahmed AL-Masri wrote:
Hi,
I would calculate the running time of my simulation code.
any one know how to do that?
example
def demo():
### the starting point of time should be 0
f.simulate(data)
### the end of the class so need to find the time in Sec.?
###
Hi,
I would calculate the running time of my simulation code.
any one know how to do that?
example
def demo():
### the starting point of time should be 0
f.simulate(data)
### the end of the class so need to find the time in Sec.?
### print time in sec.
if
Kent Johnson wrote:
> Norman Khine wrote:
>> Hello,
>> I am having difficulties in converting the following to display the
>> difference that has passed in hours and seconds in a nice way.
>>
>> from datetime import datetime
>> now = datetime.now()
>> posted = date
>> difference = now - posted
>>
Hello,
I am having difficulties in converting the following to display the
difference that has passed in hours and seconds in a nice way.
from datetime import datetime
now = datetime.now()
posted = date
difference = now - posted
namespace['date'] = date
namespace['posted'] = difference
when I l
Norman Khine wrote:
> Hello,
> I am having difficulties in converting the following to display the
> difference that has passed in hours and seconds in a nice way.
>
> from datetime import datetime
> now = datetime.now()
> posted = date
> difference = now - posted
>
> namespace['date'] = date
>
Hello,
I am having difficulties in converting the following to display the
difference that has passed in hours and seconds in a nice way.
from datetime import datetime
now = datetime.now()
posted = date
difference = now - posted
namespace['date'] = date
namespace['posted'] = difference
when I l
> So the input doc would be grepped for times and i could just
> uncomment the line i need and get he format my boss wants at this
> particular moment.
You shouldn't need to uncomment it if you can specify an
argument that describes which format you want. Then have
a bunch of formatting func
kevin parks wrote:
> I have been handed a huge number of documents which have hundreds of
> pages of times and durations, all calculated and notated by several
> different people over the course of many years. Sadly, no made any
> guidelines at all about how this work would proceed and all th
kevin parks wrote:
> I have been handed a huge number of documents which have hundreds of
> pages of times and durations, all calculated and notated by several
> different people over the course of many years. Sadly, no made any
> guidelines at all about how this work would proceed and all th
I have been handed a huge number of documents which have hundreds of
pages of times and durations, all calculated and notated by several
different people over the course of many years. Sadly, no made any
guidelines at all about how this work would proceed and all the
documenters had their o
Hi Rich
I guess passing a reference to the database handler instance that
contains closeDB to your app's __init__ is less dirty that having a
global variable, what do you think?
Hugo
>
>When I test the application and try to close it, python complains
>File "eikos.py", line 315, in On
On Thu, 9 Feb 2006, Alan Gauld wrote:
> Those who come from a life sciences background or a traditional engineering
> background can usually transition much more easily because they are used to
> thinking in terms of systems of linked objects and their interactions.
Alan,
I suppose, then, tha
> As my software engineering colleague so tactfully and sensitively put
> it,
> it's very difficult for someone who's spent decades writing procedural
> code
> as a non-professional to stop thinking procedurally when working with an
> object-oriented language.
Actually its just as hard for pro
On Thu, 9 Feb 2006, Alan Gauld wrote:
> I love the way you post problems and also post a possible
> solution - usually the correct one! :-)
Alan,
Well, I try to be helpful.
> Yes that's the problem.
And so I fixed that last evening.
As my software engineering colleague so tactfully
Rich,
I love the way you post problems and also post a possible
solution - usually the correct one! :-)
> I've tried changing OnFileQuit to call DBinterface.closeDB(), but that
> doesn't work. Obviously I still haven't completely grokked how to refer in
> one class to a method defined in anoth
On Wed, 8 Feb 2006, Kent Johnson wrote:
> OK. Suppose I have
Sigh. I was going too fast and, of course, I got ahead of myself.
> To use this class, I have to instantiate it:
> myDb = DB()
Yes, that's all in the example's __main__ and I didn't put it in my
application. Will do so right a
Rich Shepard wrote:
> On Wed, 8 Feb 2006, Kent Johnson wrote:
>
>> Evidently closeDb is an instance method of some class you don't show
>> here.
>> Does DBinterface create and maintain a single instance of this class? or
>> some other code creates an instance?
>
>
> Kent,
>
> closeDB() is de
On Wed, 8 Feb 2006, Kent Johnson wrote:
> Evidently closeDb is an instance method of some class you don't show here.
> Does DBinterface create and maintain a single instance of this class? or
> some other code creates an instance?
Kent,
closeDB() is defined in the class DBinterface. That's th
Rich Shepard wrote:
>In my wxPython application the UI is run out of class MyFrame. The method
> associated with File->Quit is called OnFileQuit. All the code for pysqlite is
> in another class called DBinterface, and that has a method closeDB():
>
>def closeDb(self):
> """
> Clo
In my wxPython application the UI is run out of class MyFrame. The method
associated with File->Quit is called OnFileQuit. All the code for pysqlite is
in another class called DBinterface, and that has a method closeDB():
def closeDb(self):
"""
Closes the database connection explic
> Anyway, I found a library for working with time zones
> http://pytz.sourceforge.net/
Thanks for pointing this one out, it looks good.
As someone who once commisioned a research paper on Time Zones and
programming I must say this looks like one of the most complete timezone
sites around. Howeve
Anyway, I found a library for working with time zones
http://pytz.sourceforge.net/
Hugo González Monteverde wrote:
> What I usually do is convert them all to UNIX epoch and then substact
> the values in seconds:
>
> >>> import time
> >>> early = time.time()
> >>> sleep(5)
> >>> time.sleep(5)
> >
What I usually do is convert them all to UNIX epoch and then substact
the values in seconds:
>>> import time
>>> early = time.time()
>>> sleep(5)
>>> time.sleep(5)
>>> late = time.time()
>>> print late - early
5.7889997959
>>>
Jonas Melian wrote:
> I would get the local time of a country
I wanted to sum two time values:
-02:30
+01:00
--
-01:30
I found one solution:
>>> time_local = dt.time(2,30)
>>> time_str = str(time_local).split(':')
Now I'll can get the first value, convert to integer and sum it.
Kent Johnson wrote:
>Jonas Melian wrote:
>
>
>>I would get th
Jonas Melian wrote:
> I would get the local time of a country, using UTC (Universal Time
> Coordinated) and DST (Daylight SavingTime) of that country.
>
> An example, utc time -02:30 and dst +1 :
>
> country_utc = datetime.time(2,30)
> isUTCNegative = True
> dst = datetime.time(1,0)
>
> Now I w
I would get the local time of a country, using UTC (Universal Time
Coordinated) and DST (Daylight SavingTime) of that country.
An example, utc time -02:30 and dst +1 :
country_utc = datetime.time(2,30)
isUTCNegative = True
dst = datetime.time(1,0)
Now I would the difference of both times.
-02:3
paul brian wrote:
>You are fairly close
>
>
>
t1 = today()
t1
>
>
>
t2 = today() + RelativeDateTime(hours=20)
t2
>
>
>
t3 = t2 - t1
t3.hours
>20.0
>
>
slice = t3/20
slice
>
>
>t3 is a "D
You are fairly close
>>> t1 = today()
>>> t1
>>> t2 = today() + RelativeDateTime(hours=20)
>>> t2
>>> t3 = t2 - t1
>>> t3.hours
20.0
>>> slice = t3/20
>>> slice
t3 is a "Delta" - that is an abstract representation
of time - it is not the 20 hours since midnight, just 20 hours
at any time in th
Hey there,
i use mx.DateTime.RelativeDateTimeDiff to get the difference between
date_x and date_y.
what i need to do divide this amount of time into 20 different times
that spaced out between the date_x and the date_y.
so if the difference between date_x and date_y is 20 hours, i need 20
DateT
On Windows it looks like msvcrt will give you a non-blocking terminal
read -- on mac / *nix systems it looks a little trickier:
http://mail.python.org/pipermail/pythonmac-sig/2004-February/010140.html
The os module in windows doesn't even have O_NONBLOCK. That seems like trouble.
m
On Sun, 20
I really don't think you can have a common way to do this on both
systems. First, the way to kill a process is quite different on both
systems (the os.kill function works only on UNIX systems, and I don't
know is there is such a function available in Python for MS Windows).
Then, I really doubt
Hi,
I want to know how to do this:
I have an executable file, which reads input from stdin provided
output at stdout or stderr.
I have to run it for a specific period of time (say 5 secs), get the
output and display it.
If i use popen(), this way:
from subprocess import *
p = Popen(["test","test.ou
And I just noticed an error in my correction code!
if len(splitLine) = 5 should be -
if len(splitLine) == 6
Gah
On Thu, 13 Jan 2005 11:48:03 +1300, Liam Clarke <[EMAIL PROTECTED]> wrote:
> I'm real sorry.
>
> My standard disclaimer is now amended to include - "Never post untested code"
>
> Dis
I'm real sorry.
My standard disclaimer is now amended to include - "Never post untested code"
Disregard everything I wrote above. I feel real bad, so bad that I did
something I very rarely do... write complete code.
See attached txt file. Guaranteed to work, if you still want to turn
Item_4 D
thanks everyone... I will look at all the various appraoches folks came
up with and see what i can learnn from them. I ended doing something
lame -- a brute force method. I formmatted and reformatted my input
data and stuffed it in a HUGE dictionary it was stupid and
kludgy i hope to st
It's kind of easy -
so that stuff you've got there is in a file called dude.inp, for
argument's sake -
import datetime
filename=file("dude.inp","r")
lineList=filename.readlines()
filename.close()
for line in lineList:
#This is the hard bit, formatting your in dates
splitLine=line.
I also notice that there is the is the 'datetime' module, which is new
to version 2.3, which i now have access to. My feeling is that this
will do much of what i want, but i can't get my head round the standard
library reference stuff
http://www.python.org/doc/lib/module-datetime.html
I don't h
I am still working on it and also fixing the input data. I think for
simplicity and consistency's sake i will have *all* time values input
and output as hh:mm:ss maybe that would be easier for now.. so i am
editing the input stuff now...
so it should all look like:
Item_1, DAT_1, 1, 00:00:23, 0
Quoting "Jacob S." <[EMAIL PROTECTED]>:
> > The old mx.datetime module (on which Python's datetime module is based, I
> > presume) had a strptime() function which would basically do the reverse (you
> > specify a format string and it would attempt to parse the date string you
> > give
> > it). Un
Forgot to mention -- screwed up before. In my proposed try/except block,
etc. I forgot to do unit conversion.
Jacob
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
> The old mx.datetime module (on which Python's datetime module is based, I
> presume) had a strptime() function which would basically do the reverse
(you
> specify a format string and it would attempt to parse the date string you
give
> it). Unfortunately, Python's datetime module doesn't have su
Quoting "Jacob S." <[EMAIL PROTECTED]>:
> I don't think so. (correct me if I'm wrong) The datetime module is for
> making date and time instances that you can add and subtract to get
> timedelta objects. Other things involved of course, but I don't think it
> has anything to do with parsing and
>
I don't think so. (correct me if I'm wrong) The datetime module is for
making date and time instances that you can add and subtract to get
timedelta objects. Other things involved of course, but I don't think it has
anything to do with parsing and
pretty printing columns of times. I'm not sure, don
Would this do the trick?
stringtime = '12:34' ## This is the column with the time 12:34 is an
example
time = stringtime.split(":")
time = [int(x) for x in time]
time.reverse()
seconds = time[0]+time[1]
try:
seconds += time[2]
except IndexError:
pass
print seconds
I'm almost sure there
Thanks for this Everyone!
Trying to work with all the stuff folks are giving me on this i a have
come across a problem... down
the line i notice that some of the times will also have an hour as well
as in H:M:S (e.g. 1:22:40)
so in some cases i would need to convert H:M:S to sec and some just M:
kevin parks wrote:
I am kind of in a bit of a jam (okay a big jam) and i was hoping that
someone here could give me a quick hand. I had a few pages of time
calculations to do. So, i just started in on them typing them in my
time calculator and writing them in by hand. Now i realize, that i
rea
On Tue, 11 Jan 2005, kevin parks wrote:
> but as always you may notice a wrinkle some items have many times
> (here 6) indicated:
>
> Item_3TAPE_139:4110:41
> Item_3TAPE_1410:4711:19
> Item_3TAPE_1511:2111:55
> Item_3TAPE_1611:58
12:18:15PM -0500, kevin parks wrote:
> From: kevin parks <[EMAIL PROTECTED]>
> Date: Tue, 11 Jan 2005 12:18:15 -0500
> To: tutor@python.org
> Cc: Kevin Parks <[EMAIL PROTECTED]>
> Subject: [Tutor] Time script help sought!
>
> I am kind of in a bit of a jam
I am kind of in a bit of a jam (okay a big jam) and i was hoping that
someone here could give me a quick hand. I had a few pages of time
calculations to do. So, i just started in on them typing them in my
time calculator and writing them in by hand. Now i realize, that i
really need a script t
70 matches
Mail list logo