Verbosity Check Style

Marc Boeren m.boeren at guidance.nl
Thu Aug 12 11:35:37 EDT 2004



> I would like to get people's views on the best way to
> implement verbosity (or any command-line option) into python
> scripts. 

I'm not sure about the best way, but this hack looks nice:

>>> def print_verbose(txt):
...     print txt
...
>>> def pass_verbose(txt):
...     pass
...
>>> def func():
...   i = 1
...   verbose('message!')
...   i+= 1
...   return i
...
>>> verbose = print_verbose
>>> func()
message!
2
>>> verbose = pass_verbose
>>> func()
2

An extra log_verbose is easily created as well.

Cheerio, Marc.



More information about the Python-list mailing list