Debugging flags [was: Re: PEP 285: Adding a bool type]
phil hunt
philh at comuno.freeserve.co.uk
Mon Apr 1 15:30:11 EST 2002
On Mon, 1 Apr 2002 08:05:24 -0500, Steve Holden <sholden at holdenweb.com> wrote:
>"phil hunt" <philh at comuno.freeserve.co.uk> wrote ...
>[...]
>> I've gone through some of my herbivore code, looking to see where
>> I've used 0 or 1 as a boolean. Example 1:
>>
>> debug = 0 # debugging this module?
>>
>> Frankly, if that is unclear to anyone, they are not cut out to be a
>> programmer. Bear in mind that most non-programmers are aware of the
>> 0/1 paradigm for boolean values: it appears on much electrical
>> equipment.
>>
>I find it much more helpful to use
>
> debug = (1, 2, 7, 93) # debugging parsing, tree build, code generation
>and error messages
>
>with corresponding tests like
>
> if 7 in debug:
> ...
I do that for logging. The debug flags are specific to a particular
module: they switch debugging on or off for that module, which is
all the granularity I need.
--
<"><"><"> Philip Hunt <philh at comuno.freeserve.co.uk> <"><"><">
"I would guess that he really believes whatever is politically
advantageous for him to believe."
-- Alison Brooks, referring to Michael
Portillo, on soc.history.what-if
More information about the Python-list
mailing list