classification
Title: PEP 8 CapWords reference wrong?
Type: Stage: resolved
Components: Documentation Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Amit.Saha, berker.peksag, docs@python, r.david.murray
Priority: normal Keywords:

Created on 2018-05-13 03:54 by Amit.Saha, last changed 2018-05-13 11:20 by r.david.murray. This issue is now closed.

Messages (4)
msg316446 - (view) Author: Amit Saha (Amit.Saha) * Date: 2018-05-13 03:54
PEP 8 suggests class names and type variable names to be in CapWords case. However:

>>> import string
>>> string.capwords('CapWord')
'Capword'

Wondering if this this an oversight or am I misunderstanding something?
msg316453 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-05-13 06:13
'CapWord' is a single word so string.capwords() works as documented:

    Split the argument into words using str.split(), capitalize each word
    using str.capitalize(), and join the capitalized words using str.join().

https://docs.python.org/3/library/string.html#string.capwords

You can also see this in the REPL:

    >>> "CapWord".split()
    ['CapWord']
    >>> _[0].capitalize()  # '_' is a shortcut for the latest command
    'Capword'
msg316460 - (view) Author: Amit Saha (Amit.Saha) * Date: 2018-05-13 11:16
Thanks for the reply.  I think I was not clear - the behavior of string.capitalize() is correct as per documentation. But the PEP8 referring to CapWords as cap words case is the bit I am not clear about, since `Capwords` back when you call `string.capwords('CapWords') and not `CapWords`.

(Just reopening so that it doesn't get lost)
msg316462 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2018-05-13 11:20
In PEP 8 'CapWords" does not refer to the capwords function, as is fairly clear from context.  A big clues is that it is not spelled 'capwords', and case matters in python function names :)  I can understand your getting confused, but that sentence is trying to list the various names give to this style of naming, and "CapWords" is one of those names, so I don't know that we should delete it.
History
Date User Action Args
2018-05-13 11:20:06r.david.murraysetstatus: open -> closed


messages: + msg316462
nosy: + r.david.murray
2018-05-13 11:16:33Amit.Sahasetstatus: closed -> open

messages: + msg316460
2018-05-13 06:13:37berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg316453

resolution: not a bug
stage: resolved
2018-05-13 03:54:59Amit.Sahacreate