flux0987
flux0987

Reputation: 87

what's the difference in below two statements for string formatting?

For any defined valriable 'e', what's the difference b/w:

logging.info("variable is : %s" % e) and loggin.info("variable is : ", e)

and when to use what? which one will be better for UTs ?

Upvotes: 0

Views: 38

Answers (1)

Francisco
Francisco

Reputation: 11486

The second one will throw an exception if you have info logging enabled, you should use logging.info("variable is : %s", e), this way you only format the string if the message is going to be logged.

Upvotes: 1

Related Questions