Hi guys ,
I am a C++ and Java programmer and i just started learning Python . It seemed that it has a very simple syntax , it is powerful actually but there is something that i havent been able to comprehend . We know that we can make an instance private member by adding "__" at the beginning . However as i just discovered any private data can be reached just by calling it _ClassName__MemberName . So what is the goal of using private data ? Thanks for replies .
Python sees private data differently. Variables are private by convention, not by force, it should be assumed by you if you distribute Python code that your users will keep the data private for the sake of not using your objects internals, but forcing the issue makes it so the few times a programmer who knows what he's doing when it could potentially be helpful is more damaging than helpful.
Simply put, a truly "private" variable does not exist in Python, instead you have variables that are private by convention. This is one of many ways Python does things differently.
Wow I changed my sig!
thx zeke i guess it's one of the weird things in python for non python programmers .
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks