On Wed, May 5, 2021 at 11:43 PM Shreyan Avigyan
<pythonshreya...@gmail.com> wrote:
>
> Private methods, functions and variables are very common in programming 
> languages. But Python doesn't support private. It has conventions for naming 
> so considered private but not private. Most of the time private is never 
> required, what Python provides is more than enough. But the need for private 
> come into place when we're dealing with passphrases and servers. For example 
> consider this code,
>
> class A:
>     def get():
>         // code to get the password
>         self.password = password
>
> Now consider this,
>
> >>> x = A(); x.get(); x.password
>
> See what just happened? Someone just got the member variable value that the 
> person wasn't supposed to.
>

That's only a problem if you have untrusted code running in the same
Python interpreter as privileged code. There's fundamentally no way
that you can get the password without the untrusted code also being
able to get it. Do you have an actual use-case where you have
passphrases like this? How does the "code to get the password" do it,
and how do you ensure that the unprivileged code can't just do the
same thing?

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/OEUKVHQO6WGKCNX462NJL4SJ6UNIWS3I/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to