You can define class variables multiple ways in Python, but they also work differently. Underscore is used for "private" or "protected" variables, altough there are no such definitions in Python. There there are class based variables and instance based variables. See code snippet for clarification.
Source code viewer
class MyClass: """Defining class variables. """ #: Class based public variable. classVariable = None #: Class based "Private" variable. _classVariable = None def __init__(self): #: Instance based public variable. self.instanceVariable = None #: Instance based "Private variable" self._instanceVariable = NoneProgramming Language: Python