[Python-Dev] Naming conventions in Py3K

Thomas Wouters thomas at xs4all.net
Fri Dec 30 16:51:34 CET 2005


On Fri, Dec 30, 2005 at 10:16:43AM -0500, Barry Warsaw wrote:
> On Thu, 2005-12-29 at 22:29 -0600, Ka-Ping Yee wrote:
> > In a fair number of cases, Python doesn't follow its own recommended
> > naming conventions.  Changing these things would break backward
> > compatibility, so they are out of the question for Python 2.*, but
> > it would be nice to keep these in mind for Python 3K.
> > 
> >     Constants in all caps:
> >         NONE, TRUE, FALSE, ELLIPSIS

> Just from a practical standpoint, I'm -1 on this.  These names (at least
> the first three) are typed /so/ often in Python programs, just think of
> the finger pain caused by excessive use of the shift key.  Now, I
> personally swap capslock and control so it would be a PITA <wink> for
> me, but doable.  But I know a lot of people who disable capslock
> altogether so they'd be performing all kinds of pinkie stretching
> gymnastics all the time.

Well, we all know code is read many more times than written, so that's a bit
of a weak argument. Personally, I'd be -1 on this because just reading the
example makes me want to jerk upright, stand at attention, salute and shout
"SIR SORRY I ASKED SIR".

There's a lot to be said for consistency and accomodating newbies (given
that we assume oldbies are already used to the current Spelling.) For
example, I've encountered many new programmers who are confused by the (lack
of) difference between builtins and variables. This would seem to be an
argument to use a form of sigils or declarations to indicate variables.
Peronally, I prefer to explain the (lack of) difference, and trust in the
fact that they'll encounter the situation in real code often enough not to
have a problem with it.

The same can be said for the suggested changes (except the stdlib modules.)
I've never seen anyone be confused about int vs Int, None vs none vs NONE,
etc. It's also not hard to get used to the particular spelling in each case;
there's more than enough exposure to burn it into even the casual
programmer's mind. And that is how people will remember it. Not by some rule
("oh, it's a constant, it has to be all caps") but by seeing it all caps all
the time. This also suggests people actively using the old names in Py3K (by
using None = NONE or what not) will actively be inhibiting the acceptance of
the new names ;)

This is all much less the case with stdlib modules, I guess, and I see no
real objection to making those conform to PEP 8.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!


More information about the Python-Dev mailing list