Python: Naming with Acronyms
Question: In Python code, what is the canonical way of dealing with well-known acronyms
when naming classes, methods and variables?

Consider, for example, a class dealing with RSS feeds. Would that rather be
this:

    
    
    class RSSClassOne:
        def RSSMethod(self):
            self.RSS_variable = True
    
    class ClassRSSTwo:
        def MethodRSS(self):
            self.variable_RSS = True
    

or this:

    
    
    class RssClassOne:
        def rssMethod(self):
            self.rss_variable = True
    
    class ClassRssTwo:
        def MethodRss(self):
            self.variable_rss = True
    

I.e. what is more important, keeping the acronym capitalization or the
recommendations of PEP 008?

**Edit:** from the answers, I conclude that this would be the way to go:

    
    
    class RSSClassOne:
        def rss_method(self):
            self.rss_variable = True
    
    class ClassRSSTwo:
        def method_rss(self):
            self.variable_rss = True
    


Answer: Well, it turns out that PEP 8 already has this topic covered
[here](http://legacy.python.org/dev/peps/pep-0008/#descriptive-naming-styles):

> Note: When using abbreviations in CapWords, capitalize all the letters of
> the abbreviation. Thus `HTTPServerError` is better than `HttpServerError`.

In other words, the Python convention for names containing acronyms is:

  1. Keep acronyms uppercase in class names (usually, the only part of Python that uses CapWords).

  2. Everywhere else, make them lowercase in order to comply with the other [naming conventions](http://legacy.python.org/dev/peps/pep-0008/#naming-conventions).

Below is a demonstration with the [`ipaddress`
module](http://docs.python.org/3/library/ipaddress.html):

    
    
    >>> import ipaddress  # IP is lowercase because this is a module
    >>> ipaddress.IPv4Address  # IP is uppercase because this is a class
    <class 'ipaddress.IPv4Address'>
    >>> ipaddress.ip_network  # IP is lowercase because this is a function
    <function ip_network at 0x0242C468>
    >>>
    

