Issue33478
Created on 2018-05-13 03:54 by Amit.Saha, last changed 2022-04-11 14:59 by admin. 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) * ![]() |
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) * ![]() |
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 |
| 2022-04-11 14:59:00 | admin | set | github: 77659 |
| 2018-05-13 11:20:06 | r.david.murray | set | status: open -> closed messages:
+ msg316462 |
| 2018-05-13 11:16:33 | Amit.Saha | set | status: closed -> open messages: + msg316460 |
| 2018-05-13 06:13:37 | berker.peksag | set | status: open -> closed nosy:
+ berker.peksag resolution: not a bug |
| 2018-05-13 03:54:59 | Amit.Saha | create | |
