[Python-Dev] static int debug = 0;

Guido van Rossum guido@beopen.com
Thu, 31 Aug 2000 23:36:05 -0500

> Jeremy Hylton writes:
>  > The change is redundant, as several people pointed out, because the C
>  > std requires debug to be initialized to 0.  I didn't realize this.
>  > Inadvertently, however, I made the right change.  The preferred style
>  > is to be explicit about initialization if other code depends on or
>  > assumes that it is initialized to a particular value -- even if that
>  > value is 0.

>   According to the BDFL?  He's told me *not* to do that if setting it
> to 0 (or NULL, in case of a pointer), but I guess that was several
> years ago now (before I went to CNRI, I think).

Can't remember that now.  I told Jeremy what he wrote here.

>   I need to get a style guide written, I suppose!  -sigh-


>   (I agree the right thing is to use explicit initialization, and
> would go so far as to say to *always* use it for readability and
> robustness in the face of changing code.)

No -- initializing variables that are assigned to first thing later is
less readable.  The presence or absence of the initialization should
be a subtle hint on whether the initial value is used.  If the code
changes, change the initialization.

--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)