Constant class attribute style according to PEP8: uppercase or lowercase?

Viewed 6774

I really like to follow the standard coding style, but can't find an answer on this.

class Card:
    """Card class representing a playing card."""
    RANKS = (None, 'Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10',
             'Jack', 'Queen', 'King')
    SUITS = ('Clubs', 'Spades', 'Diamonds', 'Hearts')

    def __init__(self, rank, suit):
        self.rank = rank
        self.suit = suit

    def __str__(self):
        return f"{Card.RANKS[self.rank]} of {Card.SUITS[self.suit]}"


c = Card(1, 1)
print(c)

Should I write constants in class attributes all_lower_case or ALL_UPPER_CASE? PEP8 just says that constants should be ALL_UPPER_CASE at the module level. What about classes?

2 Answers
Related