huh??? weird problem

Chris Rebert clp2 at rebertia.com
Fri May 14 20:29:55 EDT 2010


On Fri, May 14, 2010 at 5:14 PM, cerr <ron.eggler at gmail.com> 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? :(

print type(WarnTimeout)

I suspect it won't be numerical. Where is WarnTimeout assigned its value?
Note that in Python 2.x, comparisons between e.g. numbers and strings
were allowed, but the ordering was arbitrary.
Python 3.x fixes this and instead raises TypeError for such
nonsensical comparisons.

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list