mardi 28 janvier 2020

how to enable or disable many print statements in python with log?

the code looks like this - has many prints for debug purposes. I want to have some toggle 'button' , one liner that enables/disables those print statements. without commenting out/in.

#age
            if (row['age'] < 25.0):
                print()
                print('age < 25')
                score += -45.0
                print('score changed to : %d ' % score)

            elif (row['age'] >= 25.0) and (row['age'] < 29.0):
                print()
                print('25 < age < 29')
                score += -22.0
                print('score changed to : %d ' % score)

            elif (row['age'] >= 29.0) and (row['age'] < 35.0):
                print()
                print('29 < age < 35')
                score += 1.0
                print('score changed to : %d ' % score)

            elif (row['age'] >= 35.0):
                print()
                print('age > 35')
                score += 19.0
                print('score changed to : %d ' % score)

            #f27
            if (row['f27']== ''):                
                print()
                print('f27 missing found')
                score += -18.0
                print('score changed to : %d ' % score)

Aucun commentaire:

Enregistrer un commentaire