In an effort to write pythonic code, I wonder is there a style guide covering the use of quiet or verbose options for functions.
For example, in my Python package I have a range of functions which call each other, thus it is desirable for the user to be able to request a printed output at times.
For example:
def simple_addition(a, b, silent=True):
res = a + b
if not silent: print('The answer is %i' % res)
return res
Is there a standard arg name here. e.g. Should "quiet" / "silent" be used to suppress all printed outputs. Or should "verbose" be used to demand this if True?
Basically you can use the
logging
module which gives you the ability to set the Level of logging you want, and the logger will save/print/export (based on your config) the logged values.You can set the level of your logger using:
And there are many more options there.