[Python-Dev] PEP 8 updates/clarifications, function/method style

Guido van Rossum guido at python.org
Wed Dec 14 19:17:45 CET 2005

On 12/14/05, Wolfgang <wl at flexis.de> wrote:
> Hello,
> PEP 8 for function and method names:
> -----
> 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.
> -----
> We need a clear style for function and method names
> now std lib uses "foo_bar" sometimes "foobar"
> and sometimes "fooBar".

Actually this (function, method and ivar names) is such a contentious
issue that I think the style guide should explicitly allow all
two/three styles and recommend to be consistent within a class, module
or package.

I want to be adamant about module, package and class names though:
module/package names should be short all-lowercase without
underscores; class names should be CapWords. I'd like to fix this for
StringIO.py, UserDict.py etc.

> The use of lowercase with underscores is the default so
> the python std lib should use it in all modules.

Too late. I don't think the diversity is all that distracting. I'd be
much more concerned about spelling MethodNames (as unfortunately the
Google style guide requires).

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list