+ 2

How can we provide security if there is no access specifiers in python??

As private and protected members can be accessed by using class name outside the class .

14th Jul 2020, 3:19 PM
Renuka Chhalotre
Renuka Chhalotre - avatar
3 Réponses
+ 3
There is no such thing as privacy in Python. You just use underscores to declare the variables as private so that they could not be directly modified outside the class. But actually you can do that using the class name as you said. This is generally called name mangling and used so that the variable does not clash with another variable in a sub class. __variable is replaced with- _className__variable Here is small code demonstration. https://code.sololearn.com/cN3CJ80EyerJ/?ref=app
14th Jul 2020, 5:26 PM
Avinesh
Avinesh - avatar
+ 7
security... who needs security???? The security is the experienced coder. Best are those, who already had a big crash with it😉😉 Sounds funny but has a lot if truth in it.
14th Jul 2020, 3:27 PM
Oma Falk
Oma Falk - avatar
+ 4
Private and protected members can't be accessed *directly* outside the class.
14th Jul 2020, 3:24 PM
Arsenic
Arsenic - avatar