Re: Python equivalent for C module

2008-10-21 Thread Bruno Desthuilliers
Derek Martin a écrit : On Mon, Oct 20, 2008 at 07:29:16PM +0200, Bruno Desthuilliers wrote: This should have been: fprintf(STDERR, "DEBUG: %s", msg); No, it shouldn't have. If I turn on debugging, I want the debug messages to go to stdout, so that they can be captured along with the out

Re: Python equivalent for C module

2008-10-21 Thread Ville M. Vainio
Vinay Sajip <[EMAIL PROTECTED]> writes: > import logging > > logging.warning("Message with %s data", "variable") # or debug, info, > error > > and I'd like to know what simpler interface you think would be better/ > easier to grok for quick hack jobs. It's not the logging itself that is a probl

Re: Python equivalent for C module

2008-10-21 Thread Vinay Sajip
On Oct 20, 9:08 pm, [EMAIL PROTECTED] (Ville M. Vainio) wrote: > Unfortunately these square-wheeled homegrown solutions are easier to > grok than the standardloggingmodule. It seems to target more > "serious" applications at the cost of feeling a bit too clunky for > quick hack jobs. I'm surprised

Re: Python equivalent for C module

2008-10-20 Thread Derek Martin
On Mon, Oct 20, 2008 at 10:28:15AM -0700, Gary Herron wrote: > > The other weird behavior was, once I changed the value of DEBUG, > > dprint() started to behave oddly. No matter what I passed as an > > argument (and no matter what I set the value of DEBUG to be), it > > started printing the exact

Re: Python equivalent for C module

2008-10-20 Thread Derek Martin
On Mon, Oct 20, 2008 at 10:43:55PM +, Steven D'Aprano wrote: > All of this is just splitting hairs, Indeed... :) > because you don't really mean Python is making a copy of the name > 'DEBUG', but of the *data* that DEBUG refers to, namely the object > True. Well, as long as we're having se

Re: Python equivalent for C module

2008-10-20 Thread Aaron Brady
On Oct 20, 3:08 pm, [EMAIL PROTECTED] (Ville M. Vainio) wrote: > Bruno Desthuilliers <[EMAIL PROTECTED]> 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 impoli

Re: Python equivalent for C module

2008-10-20 Thread Steven D'Aprano
On Mon, 20 Oct 2008 17:09:25 -0400, Derek Martin wrote: > On Mon, Oct 20, 2008 at 07:29:16PM +0200, Bruno Desthuilliers wrote: >> This should have been: >> >> fprintf(STDERR, "DEBUG: %s", msg); > > No, it shouldn't have. If I turn on debugging, I want the debug > messages to go to stdout,

Re: Python equivalent for C module

2008-10-20 Thread Derek Martin
On Mon, Oct 20, 2008 at 07:29:16PM +0200, Bruno Desthuilliers wrote: > This should have been: > > fprintf(STDERR, "DEBUG: %s", msg); No, it shouldn't have. If I turn on debugging, I want the debug messages to go to stdout, so that they can be captured along with the output (of which there i

Re: Python equivalent for C module

2008-10-20 Thread Bruno Desthuilliers
Ville M. Vainio a écrit : Bruno Desthuilliers <[EMAIL PROTECTED]> 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, whic

Re: Python equivalent for C module

2008-10-20 Thread Ville M. Vainio
Bruno Desthuilliers <[EMAIL PROTECTED]> 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

Re: Python equivalent for C module

2008-10-20 Thread Bruno Desthuilliers
Derek Martin a écrit : I'd like to know if it's possible to code something in Python which would be equivalent to the following C: [Assume bool is typedef'd to int, and TRUE and FALSE are #defined to 1 and 0, respectively] debug.c #include bool DEBUG; void dprint(char *msg) {

Re: Python equivalent for C module

2008-10-20 Thread Aaron Brady
On Oct 20, 12:19 pm, Derek Martin <[EMAIL PROTECTED]> wrote: snip > > I'm specifically trying to avoid having to create a debug object and > pass it around... All modules should have visibility into the state of > whether DEBUG is turned on or off, and be able to use dprint().  Can > Python do this

Re: Python equivalent for C module

2008-10-20 Thread Gary Herron
Derek Martin wrote: > I'd like to know if it's possible to code something in Python which > would be equivalent to the following C: > > [Assume bool is typedef'd to int, and TRUE and FALSE are #defined to 1 > and 0, respectively] > > debug.c > #include > > bool DEBUG; > > void dprint(cha

Python equivalent for C module

2008-10-20 Thread Derek Martin
I'd like to know if it's possible to code something in Python which would be equivalent to the following C: [Assume bool is typedef'd to int, and TRUE and FALSE are #defined to 1 and 0, respectively] debug.c #include bool DEBUG; void dprint(char *msg) { if (DEBUG){