huh??? weird problem

Paul Hankin paul.hankin at gmail.com
Sun May 16 07:16:41 EDT 2010


On May 15, 3:41 am, Dave Angel <da... at ieee.org> wrote:
> cerr wrote:
> > Hi There,
>
> > I got following code:
> > start=time.time()
> > print 'warnTimeout '+str(WarnTimeout)
> > print 'critTimeout '+str(CritTimeout)
> > print 'start',str(start)
> > while wait:
> >     passed =  time.time()-start
> >     print 'passed ',str(passed)
> >     if passed >= WarnTimeout:
> >       print ' Warning!'
> >  ...
> > ...
> > ...
> > which basically means that the loops should go until the warning time
> > has been reached and then i want it to print 'warning!' and execute
> > some warning code. But weirdly enough i get following screen output:
> > warnTimeout 3
> > critTimeout 5
> > start 1273882010.43
> > passed  7.60555267334e-05
> > passed  0.998471975327
> > passed  1.99847102165
> > passed  2.9984691143
> > passed  3.99847006798
> > passed  4.998472929
> > ...
> > ...
> > any one a clue why after 3 seconds it doesn't go into the the if an
> > print 'Warning!'? That's odd... :o Crazy, what am i not seeing? :(
>
> we're not seeing all the relevant code.  While I can ignore the missing
> import, I don't see any creation of the variables WarnTimeout and
> CritTimeout.  Simplest explanation that fits your sample run is that
> they are not of type float.

Yes, and most likely str. A good debugging tip is to use repr rather
than str to print out debugging messages.

--
Paul Hankin



More information about the Python-list mailing list