Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
https://www.python.org/dev/peps/pep-0008/#method-n...
class ClassName(object):
def public_method(self):
pass
def _protected_method(self):
pass
def __private_method(self):
pass
Encapsulation in Python only works at the level of an agreement between programmers about which attributes are public and which are internal.
A single underscore at the beginning of an attribute name indicates that the variable or method is not intended to be used outside of class methods, but the attribute is available by that name.
A double underscore at the beginning of an attribute name provides more protection: the attribute becomes inaccessible by that name.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question