printf quiet mode
Posted: Wed Aug 06, 2008 6:03 pm
I've been trying to figure out a way to make functions quiet. I don't have any elegant way to do it yet, but here's what I have so far:
- Every function that prints anything is required by convention to possess a "quiet" parameter, defaulted to false.
- Every function that prints anything is required by convention to use the printf module to print.
- When calling the printf module, the "quiet" parameter is passed along to printf.
- Printf determines, though a combination of the "quiet" parameter and the warnlevel, whether or not to print anything.
Example of use:
Any thoughts?
-Rye
- Every function that prints anything is required by convention to possess a "quiet" parameter, defaulted to false.
- Every function that prints anything is required by convention to use the printf module to print.
- When calling the printf module, the "quiet" parameter is passed along to printf.
- Printf determines, though a combination of the "quiet" parameter and the warnlevel, whether or not to print anything.
Example of use:
Code: Select all
def foo(a, b, quiet = False):
printf( a + " just foobared " + b, ALL, quiet = quiet)
foo("Rye", "Matt", quiet = True)
# prints nothing
foo("Rye", "Matt")
# prints "Rye just foobared Matt"
-Rye