Python equivalent for C module

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Mon Oct 20 14:20:56 EDT 2008


Ville M. Vainio a écrit :
> Bruno Desthuilliers <bdesth.quelquechose at free.quelquepart.fr> writes:
> 
>> STDOUT is for *normal* program outputs. Debug informations,
>> warnings, and all verbosity should go to STDERR.
> 
> Actually, stderr is for errors, by convention. It's rather impolite to
> dump trivial debug info to stderr, which often "alerts" the user more
> than stdout.

If you "dump trivial debug infos" to stdout, you just break anything 
relying on stdout being for *normal* program outputs - IOW, you just can 
chain-pipe programs no more. As far as I'm concerned, it's *way* more 
impolite than "alerting" the user. Also and FWIW, most programs have 
--quiet and --verbose options that let the user specify verbosity.

>> Also and FWIW, Python has a logging module in it's stdlib. Please
>> use it instead of any half-backed squared-wheel homegrown solution.
> 
> Unfortunately these square-wheeled homegrown solutions are easier to
> grok than the standard logging module. It seems to target more
> "serious" applications at the cost of feeling a bit too clunky for
> quick hack jobs.

If it's for a "quick hack job", you don't even need anything like what 
the OP describe. For anything more serious - anything that requires more 
than one .py script file with a couple functions and a main section -, 
the couple minutes spent setting up a default logger will very quickly 
pay off.

But YMMV, of course...




More information about the Python-list mailing list