Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #89841
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <motoom@xs4all.nl> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'sys': 0.07; '"__main__":': 0.09; '%s"': 0.09; '__name__': 0.09; 'msg': 0.09; 'def': 0.12; '"\\n")': 0.16; '%s,': 0.16; 'from:addr:xs4all.nl': 0.16; 'received:194.109': 0.16; 'received:194.109.24': 0.16; 'received:194.109.24.22': 0.16; 'received:xs4all.nl': 0.16; 'wrote:': 0.18; 'module': 0.19; 'import': 0.22; '"you': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'testing': 0.29; 'raise': 0.29; 'gives': 0.31; 'faster,': 0.31; 'run': 0.32; 'subject:time': 0.33; 'skip:d 20': 0.34; 'subject:with': 0.35; "can't": 0.35; 'done,': 0.36; 'done': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'header:Message-Id:1': 0.63; 'received:194': 0.64; 'total': 0.65; 'computers': 0.72; 'received:nl': 0.74; 'done:': 0.84; 'total,': 0.84 |
| Content-Type | text/plain; charset=us-ascii |
| Mime-Version | 1.0 (Apple Message framework v1085) |
| Subject | Re: Messages with a time stamp |
| From | Michiel Overtoom <motoom@xs4all.nl> |
| In-Reply-To | <87r3qykr39.fsf@Equus.decebal.nl> |
| Date | Sun, 3 May 2015 11:10:40 +0200 |
| Content-Transfer-Encoding | quoted-printable |
| References | <87r3qykr39.fsf@Equus.decebal.nl> |
| To | Python <python-list@python.org> |
| X-Mailer | Apple Mail (2.1085) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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.56.1430644308.12865.python-list@python.org> (permalink) |
| Lines | 44 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1430644308 news.xs4all.nl 2926 [2001:888:2000:d::a6]:41543 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:89841 |
Show key headers only | View raw
On May 3, 2015, at 10:22, Cecil Westerhof wrote:
> For testing I want my messages time stamped like:
For progress reporting, I often use the module below (eta.py), which also gives a projected time of completion:
import datetime, time, sys
etastart = 0
def eta(done, total, s, reportinterval=100, datetimeformat="%d %b %H:%M:%S"):
global etastart
if done == 0:
etastart = datetime.datetime.now()
if not done % reportinterval:
noww = datetime.datetime.now()
prtnow = noww.strftime(datetimeformat)
if done:
if not isinstance(etastart, datetime.datetime): raise RuntimeError("You should call eta() at least once with done=0")
elapsed = noww - etastart
secsperitem = float(elapsed.seconds) / done
totalsecs = secsperitem * total
eta = etastart + datetime.timedelta(0, totalsecs)
prteta = eta.strftime(datetimeformat)
msg = "now %s, eta %s (%d/%d) %s" % (prtnow, prteta, done, total, s)
else:
msg = "now %s (%d/%d) %s" % (prtnow, done, total, s)
sys.stderr.write(msg + "\n")
if __name__ == "__main__":
for i in range(10):
eta(i, 10, "idling for ten seconds", 1, "%H:%M:%S")
time.sleep(1)
--
"You can't actually make computers run faster, you can only make them do less." - RiderOfGiraffes
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Messages with a time stamp Cecil Westerhof <Cecil@decebal.nl> - 2015-05-03 10:22 +0200
Re: Messages with a time stamp Michiel Overtoom <motoom@xs4all.nl> - 2015-05-03 11:10 +0200
Re: Messages with a time stamp Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-03 10:36 +0100
Re: Messages with a time stamp Cecil Westerhof <Cecil@decebal.nl> - 2015-05-03 12:08 +0200
csiph-web