Help with time
MDK
mdk at mdk.com
Fri Feb 1 13:22:21 EST 2002
"Marc Poulin" <mpoulin at verinet.com> wrote in message
news:3c5ad0bf$0$2200$7586b60c at news.frii.com...
> In article <a3ecqt$16bk9d$1 at ID-98166.news.dfncis.de>, "MDK" <mdk at mdk.com>
> wrote:
>
> > I am passing to a function how long in milliseconds I want to wait for
>
> > import time
> >
> > def getdata(ms):
> > starttime = time.time()
> > while len(data) < 20:
> > now = time.time()
> > print '%.3f seconds %.3f' % (now - starttime, timeout / 1000) if
> > now - starttime > timeout/1000:
> > break
> > return data
> >
> > What am I doing wrong?
>
> Maybe a truncation problem (mixing ints and floats)?
>
> My Python interpreter says
> >>> print 100/1000
> 0
> >>> print 100/1000.0
> 0.1
> >>>
Yes, that was it. Thanks! I never would have thought of that.
More information about the Python-list
mailing list