[Python-ideas] Pythonic access protection

Neil Girdhar mistersheik at gmail.com
Tue Mar 13 20:24:41 EDT 2018

Now that Python has type annotations has there been any thought into having 
access protection annotations.  This would be for same reason as type 
annotations: to give the linter the opportunity to catch bugs early, and to 
give the programmer a uniform way to specify invariants.

Unlike type annotations, this wouldn't need any new syntax, but it should 
be well thought-out.  My rough idea is to have some decorator on methods 
and properties describing who is allowed to call those methods and access 
those properties.  The allowed caller list could be things base classes.

I think this would need to be better thought-out, but something like this 
would be really useful for me as it's hard to keep track of who is allowed 
to call what.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180313/6b07c0e4/attachment.html>

More information about the Python-ideas mailing list