why python does not have Access modifier like in c#, java i.e public, private etc.what are the alternative way of encapsulation and information hiding in python.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
From Wikipedia:
The same sentiment is described in the We are all consenting adults paragraph of The Hitchhiker’s Guide to Python!
The alternative is to name your "private" (they are not really private in python) with identifiers that make it easy to identify that those members should not be used from outside.
For example:
However, if the class user really wants to change these attributes he will have no problem. It is his responsability not to do that.
Look at: http://docs.python.org/2/tutorial/classes.html#tut-private