473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

time factor

how do you put time as a factor in python as i'm trying to make a loop for a given time.
Mar 12 '07 #1
2 1538
bartonc
6,596 Expert 4TB
how do you put time as a factor in python as i'm trying to make a loop for a given time.
The time module as has time function that returns a floating point which is the number of seconds since January 1st 1970. The easiest thing is to:
Expand|Select|Wrap|Line Numbers
  1. from time import time, sleep
  2. now = time()
  3. endTime = now + 10  # ten seconds to run loop
  4. while now < endTime:
  5.     sleep(1)  # do something that takes some time (one second here)
  6.     now = time()
  7.     print now
Mar 12 '07 #2
Thekid
145 100+
Or depending on your goal you could try something like this:

Expand|Select|Wrap|Line Numbers
  1. from time import time
  2. startTime = time()
  3. for i in range(100):
  4.           t = time() - startTime
  5.           print i,t
  6.  
Mar 12 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Markus Dehmann | last post by:
I have a big class that contains code like this (the code is automatically generated according to some configuration): if(str == "name1"){ do; something; name1_specific; }else if(str ==...
4
by: sjoshi | last post by:
Hello I have these tables: CREATE TABLE . ( NOT NULL , NOT NULL ) ON CREATE UNIQUE CLUSTERED INDEX ON .(, ) WITH FILLFACTOR = 90 ON
4
by: flupke | last post by:
Is there an easy to convert following hour notation hh:mm to decimals? For instance 2 hours and 30 minutes as 2:30 to 2,50 I don't really know where to search for this kind of conversion. ...
4
by: Gary Davis | last post by:
Once a day or so, I receive an error on a fairly active website that calls this StrMixed.cs method constructor. 99% of the time there is no exception: System.Web.HttpUnhandledException:...
3
by: Jason S | last post by:
is there any way to use templates to bind integer/floating point constants to a template for compile-time use? e.g. template <double conversion> class meters { const factor = conversion;
5
by: Marcus | last post by:
Hi, was wondering if anyone knows a good algo for rounding time to a desired interval. For instance, I have data set that is timestamped in second resolution and I need to modify that data to be...
5
by: Ted Boyd | last post by:
Boss is concerned with security, and wants to implement a 3 - factor login system (username, password, and PIN). I'm not finding any canned products... does anybody have any suggestions?
9
by: shuisheng | last post by:
Dear All, I have little experience in coding. For a c++ code with 30,000 lines, It is large or small? For two average programmers, usually how long does it take to finish the code? The code...
2
by: entellus | last post by:
I'm using gcc to compile the code listed below when I get the following error error: expected '=', ',', ';', 'asm' or '__attribute__' before ' is_prime_number /* * What is the largest...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.