I have a program that defines the function verboseprint
to either print or not print to the screen based on a boolean:
# define verboseprint based on whether we're running in verbose mode or not
if in_verbose_mode:
def verboseprint (*args):
for arg in args:
print arg,
print
print "Done defining verbose print."
else:
# if we're not in verbosemode, do nothing
verboseprint = lambda *a: None
My program uses multiple files, and I'd like to use this definition of verboseprint in all of them. All of the files will be passed the in_verbose_mode
boolean. I know that I could just define verboseprint
by itself in a file and then import it into all of my other files, but I need the function definition to be able to be declared two different ways based on a boolean.
So in summary: I need a function that can declare another function in two different ways, that I can then import into multiple files.
Any help would be appreciated.