1# Make variables private by adding two underscored (_)
2# in front of variable names.
3
4# However, this is ***JUST A CONVENSION***.
5# Private variables doesn't exist in Python. __var is still accesible.
6
7
8# Example:
9class User(object):
10 def __init__(self, name, password):
11 self.name = name # Public variable
12 self.__password = password # Private variable
13
1# Python does not have any private variables like C++ or Java does.
2# You could access any member variable at any time if wanted, too.
3# However, you don't need private variables in Python,
4# because in Python it is not bad to expose your classes member variables.