Thursday 15 August 2013

private public protected access specifiers in python -


Can we simulate private and secure access specifiers in Python?

Name Mangling

Example:

  __ var = 10   

The person can simulate but it can be feasible to reach out easily through the object.

  object._className__var   

Is there any way we can simulate or do a solution python that I do not know?

Python does not have mandatory access control like some other languages ​​that you can use The philosophy "We are consenting to all adults".

According to the conference, private features are prefixes with an underscore, which is an indication for people that they should not be used directly, but this is only the conference, if you want sandbox python You have to do it in a different process.

The purpose of double underscore mangling is to prevent accidental name collision, not to implement access control.

No comments:

Post a Comment