improvements for the logging package

Trent Mick trentm at ActiveState.com
Thu Sep 8 13:45:32 EDT 2005


[skip at pobox.com wrote]
>     Trent> I thought PEP 8 said camelCase (or whatever it is called) was
>     Trent> okay?
> 
> Hmmm...  In the section entitled "Naming Conventions" I see:
> 
>     Function Names
> 
>       Function names should be lowercase, possibly with words separated by
>       underscores to improve readability.  mixedCase is allowed only in
>       contexts where that's already the prevailing style (e.g. threading.py),
>       to retain backwards compatibility.
> 
>     Method Names and Instance Variables
> 
>       The story is largely the same as with functions: in general, use
>       lowercase with words separated by underscores as necessary to improve
>       readability.

I swear that has changed since I last read that. :)
...checking... Guess I haven't read it in about 2 years. This patch:

    Sat Mar 20 06:42:29 2004 UTC (17 months, 2 weeks ago) by kbk 

        Patch 919256
        Clarify and standardize the format for names of modules,
        functions, methods, and instance variables.

        Consistent, I hope, with discussion on python-dev

        http://mail.python.org/pipermail/python-dev/2004-March/043257.html

        http://mail.python.org/pipermail/python-dev/2004-March/043259.html

Made this change:

    http://cvs.sourceforge.net/viewcvs.py/python/python/nondist/peps/pep-0008.txt?r1=1.20&r2=1.21

         Function Names
     
    -      Plain functions exported by a module can either use the CapWords
    -      style or lowercase (or lower_case_with_underscores).  There is
    -      no strong preference, but it seems that the CapWords style is
    -      used for functions that provide major functionality
    -      (e.g. nstools.WorldOpen()), while lowercase is used more for
    -      "utility" functions (e.g. pathhack.kos_root()).
    +      Function names should be lowercase, possibly with underscores to
    +      improve readability.  mixedCase is allowed only in contexts where
    +      that's already the prevailing style (e.g. threading.py), to retain
    +      backwards compatibility.



> Since the logging package currently uses mixedCase it would appear it
> shouldn't revert to lower_case.  I'm thinking it should have probably used
> lower_case from the start though.  I see no real reason to have maintained
> compatibility with log4j.  Similarly, I think PyUnit (aka unittest) should
> probably have used lower_case method/function names.  After all, someone
> went to the trouble of PEP-8-ing the module name when PyUnit got sucked into
> the core.  Why not the internals as well?

Perhaps because of the timing.


> If I remember
> correctly, it was more-or-less written for inclusion in the core.

Yah. It was added before Guido more clearly stated that he thought
modules should have a successful life outside the core before being
accepted in the stdlib.

Trent

-- 
Trent Mick
TrentM at ActiveState.com



More information about the Python-list mailing list