Python is an adult language

From an object-oriented perspective on the Python language, there is no language feature that enforces private access to class members (hides them from outside the class). By convention, one or two underscores (_) at the beginning of a member name indicate that it is private / must not be accessed from the outside, but prohibit those access altogether. Can't.

"We are all (consenting) adults here" --Guido van Rossum (Python language author) or the Python community

class Person:

  #Private function (_Is one)
  def _privateFun(self):
    print("private!")

  #Private function (_2)
  def __morePrivateFun(self):
    print("secret!")


target = Person()

target._privateFun()   # OK

target.__morePrivateFun()         #This is NG
target._Person__morePrivateFun()  # OK

Recommended Posts

Python is an adult language
Python> What is an extended slice?
Python in is also an operator
Python is easy
What kind of programming language is Python?
What is python
Python is instance
What is Python
[What is an algorithm? Introduction to Search Algorithm] ~ Python ~
Is sys.settrace, a python genius feature, another language?
python int is infinite
[Python] What is Pipeline ...
Introduction to Python language
What is an iterator?
[Python] What is virtualenv
[Ruby / Python / Java / Swift / JS] What is an algorithm?
Building an environment for natural language processing with Python
python (2) requires self because the method is an instance method
100 Language Processing with Python Knock 2015
Python round is not strictly round
[Python] Debugging is more efficient!
Quicksort an array in Python 3
How Python __dict__ is used
Creating an egg with python
100 Language Processing Knock Chapter 1 (Python)
What is an instance variable?
100 Language Processing Knock Chapter 2 (Python)
Python list is not a list
[Python] Python and security-① What is Python?
Python release cycle is faster!
[Python] * args ** What is kwrgs?
An introduction to Python Programming
Python: Natural language vector representation
Identity and equivalence Python is and ==
What is a python map?
Python Basic Course (1 What is Python)
[Introduction to Python] What is the most powerful programming language now?
Is Numpy's unpleasant flexibility possible because Python is a dynamically typed language?
What is Python? What is it used for?
Cut out an image with python
Python Note: About comparison using is
ppa: jonathonf / python-3.6 is now private
Use fabric as is in python (fabric3)
100 Language Processing Knock Chapter 1 in Python
Golang vs. Python – Is Golang Better Than Python?
Studying Python Part.1 Creating an environment
Python is UnicodeEncodeError in CodeBox docker
Write an HTTP / 2 server in Python
Operate an I2C-connected display from Python
[Python] What is @? (About the decorator)
Which is better, PyPy or Python?
Create an Excel file with Python3
Develop an investment algorithm in Python 2
100 Language Processing Knock with Python (Chapter 3)
Introduction to Protobuf-c (C language ⇔ Python)
[python] What is the sorted key?
I sent an SMS with Python
Python for statement ~ What is iterable ~
10 functions of "language with battery" python
There is no switch in python
Today's python error: image is blank