Data hiding python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Data hiding python

I understand data hiding in Java. I would like to understand the principle in python, the simple _ only allows to signal "warning protected attributes" without blocking anything? That's right ?

22nd Sep 2022, 9:30 PM
Roland
Roland - avatar
2 Answers
+ 2
It is a a consequence of Python's design. Also, I like the rationale that it avoids verbose codes. Here is a nice explanation I'm sure there are pros and cons to this, but 'when in Rome do as the Romans do'. https://stackoverflow.com/questions/7456807/python-name-mangling https://dirtsimple.org/2004/12/python-is-not-java.html
22nd Sep 2022, 10:34 PM
Bob_Li
Bob_Li - avatar
+ 2
Yup, in python, there's really only the suggestion of private
22nd Sep 2022, 10:09 PM
Slick
Slick - avatar