huh??? weird problem

C

cerr

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... :eek: Crazy, what am i not seeing? :(
 
C

Chris Rebert

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... :eek: 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
 
M

Mensanator

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!'?

Works for me:

warnTimeout 3
critTimeout 5
start 1273883378.39
passed 1.0
passed 2.0
passed 3.0
Warning!
passed 4.0
Warning!
passed 5.0
Warning!
passed 6.0
Warning!
passed 7.0
Warning!

That's odd... :eek: Crazy, what am i not seeing? :(

Did you copy it right?
 
D

Dave Angel

cerr said:
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... :eek: 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.

DaveA
 
P

Paul Hankin

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top