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.

I suggest to add private support for functions (module __all__ methods to be 
more clear), methods and variables (module __all__ variables or class 
variables).

(I very bad at reading PEPs so I may miss out something critical that's been 
explained already (sometimes I miss out a feature in a PEP and think about 
suggesting that feature when it's already there and then I realize "Oh! It's 
already here in this PEP"). If that's the case then please correct me.)

With Regards,
Shreyan Avigyan
_______________________________________________
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/DD2L56GCOCWEUBBZBDKKKMPPVWB7PRFB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to