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?
'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'
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)
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
2022-04-11 14:59:00
admin
set
github: 77659
2018-05-13 11:20:06
r.david.murray
set
status: open -> closedmessages: + nosy: + r.david.murray
2018-05-13 11:16:33
Amit.Saha
set
status: closed -> openmessages: +
2018-05-13 06:13:37
berker.peksag
set
status: open -> closednosy: + berker.peksagmessages: + resolution: not a bugstage: resolved