Expansion of the __debug__ and pass concepts

Janko Hauser jhauser at ifm.uni-kiel.de
Tue Oct 31 16:23:48 EST 2000


Have you tried to use assert? It looks for a logical expression, I
have note tested this, but I think the expression evaluation is
skipped if python runs with -O. Yeah I think it the case.

import time

def bigtest():
    time.sleep(10)
    return 1

a=time.time()
print '0'
assert bigtest() == 1
print time.time()-a

gives:
@porto >python test_a.py
0
9.99659597874
@porto >python -O test_a.py
0
0.0057909488678

HTH,
__Janko

-- 
  Institut fuer Meereskunde             phone: 49-431-597 3989
  Dept. Theoretical Oceanography        fax  : 49-431-565876
  Duesternbrooker Weg 20                email: jhauser at ifm.uni-kiel.de
  24105 Kiel, Germany



More information about the Python-list mailing list