Is there a convention on how class variables should be named (as different from instance variables), or is there no real difference. For example:
import pymysql
class DB:
NUM_CONNECTIONS = 0
def __init__(self):
self.conn = None
self.cursor = None
def __repr__(self):
return 'Closed connection' if not self.conn else f'Open conection @ 0x{id(self):x}'
def connect(self):
if self.conn: return
self.conn = pymysql.connect(host='127.0.0.1',user='root')
self.cursor = self.conn.cursor()
DB.NUM_CONNECTIONS += 1
Currently I usually do variables as CLASS_VARIABLES and instance_variables. What are some common patterns for this?