I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?
-
Okay, it was supposed to be SSLXMLRPCServer. :) – gregturn Sep 10 '10 at 22:19
-
I like both for different reasons. a) The first is the "proper" version of the acronym. b) The second is easier to read. – gregturn Sep 10 '10 at 22:20
-
An acronym is an abbreviation (one that can be spoken), PEP8 is clear about abbreviations: [all capitals](https://www.python.org/dev/peps/pep-0008/#descriptive-naming-styles) instead of CapsWords (with HTTPServerError as the provided example) – Anthon Jun 04 '17 at 21:16
-
Possible duplicate of [How do you PEP 8-name a class whose name is an acronym?](https://stackoverflow.com/questions/2853531/how-do-you-pep-8-name-a-class-whose-name-is-an-acronym) – Stevoisiak Oct 27 '17 at 19:35
8 Answers
This is a matter of personal preference, but I find the second format much easier to read. The fact that your first format has a typo in it (PRC instead or RPC) suggests that I am not the only one.

- 25,806
- 5
- 67
- 84
-
3.NET has an interesting take at it: 2-letter components are uppercased (most notably `IO`; I don't recall seeing any other one in 2 letters, actually), but everything else is Pascal-cased, so `Xml`, `Rpc`, `Ssl`, `Http` etc. Sounds weird, but I the people who wrote it originally just couldn't stand the pain looking at `Io`. – Pavel Minaev Sep 10 '10 at 22:28
It should be SSLXMLRPCServer, to match the standard library classes like SimpleXMLRPCServer, CGIXMLRPCRequestHandler, etc.
Adopting a naming convention that differs from equivalents in the standard library is only going to confuse people.

- 1,189
- 8
- 8
The problem with uppercase acronyms in CamelCase names is that the word following the acronym looks like a part of it, since it begins with a capital letter. Also, when you have several in a row as in your example, it is not clear where each begins. For this reason, I would probably use your second choice.

- 178,883
- 35
- 278
- 309
As stated already, PEP-8 says to use upper-case for acronym. Now, python zen also says "readability counts" (and for me the zen has priority over the PEP :-).
My opinion in such unclear situation is to take into account the standard in the programming context, not just the language. For example, some xml-http-query class should be written XMLHttpQuery
in a servlet context (w.r.t XMLHttpRequest
).
I don't know your context, but it seems XMLRPCServer
exists and you want to attach ssl to it. So you could choose something like:
SSL_XMLRPCServer
It would emphasized the XMLRPCServer
-without changing it-.
Also, you'd stay close to PEP-8 and follow the zen :-)
My 2 cents
Note: if XMLRPCServer
is not strongly related to your class and is really a standard in the domain, then you need to choose another name, as to not be confusing.

- 14,628
- 8
- 59
- 92
The PEP-8 mentions nothing about acronyms. You would be safest to keep the acronyms uppercased (it's what I see most).

- 2,876
- 19
- 19
-
10You mean, it doesn't mention it except for *Note: When using abbreviations in CapWords, capitalize all the letters of the abbreviation. Thus HTTPServerError is better than HttpServerError.* certainly... :) (It should be noted that I disagree with this recommendation.) – dash-tom-bang Sep 10 '10 at 23:49
-
2This comment should have been an answer (and then it should have been accepted as THE answer; if you're talking about what one *should* do in Python formatting, Pep-8 is where it's at). – machineghost Mar 13 '12 at 17:03
I normally uppercase acronyms. Twisted and a few other libraries do this as well.

- 68,820
- 20
- 127
- 125
I had this problemlots of time . I uppercase Acronym but I doesn't like it because when you chain them (as in your example) it doesn't feel right. However I think the best things to do is to make a choice and stick to hit, so at least don't you know when you need to reference something how it's written without having to check (which is one of the benefit of coding standard)

- 22,276
- 7
- 60
- 102
-
It doesn't feel right until you decide to start doing it. Then you get really irritated by software that jams acronyms together making them impossible to parse. – dash-tom-bang Sep 10 '10 at 23:50
-
Except in our case : SSLXMLRPCServer is just really hard to read, and so can't feel right (even if it's the best solution) – mb14 Sep 11 '10 at 08:23
How about SSL_XML_RPC_Server
for acronymity and readability?
It's what I often do when I want to avoid camel-case for some reason.

- 119,623
- 25
- 170
- 301
-
I think mixing camel case and snake case, is the worth you can do. In my opinion, you should choose one way of naming stuff and stick to it, without exception. – mb14 Sep 11 '10 at 08:24
-
1@mb14: "Special cases aren't special enough to break the rules. Although practicality beats purity." Is readability a practical characteristic? – Juh_ Aug 06 '14 at 13:13
-
1
-
@Juh_: Readability's a practical characteristic, sense "practicality" usually means a "concern with actual use". – martineau Aug 06 '14 at 16:53