Will python never intend to support private, protected and public?

Steve Holden steve at holdenweb.com
Fri Sep 30 04:01:14 EDT 2005


Antoon Pardon wrote:
> Op 2005-09-29, Steve Holden schreef <steve at holdenweb.com>:
> 
> 
>>Think about it: we have a language that has an eval() function and an 
>>exec statement, and people are concerned that some service consumer 
>>shouldn't be allowed to go poking around inside namespaces? What do we 
>>have to do, put up signs saying "do not stab yourself with a knife"? If 
>>people want control without discipline (which is effectively what 
>>private and the like purport to do) then Python just may not be your 
>>language ...
> 
> 
> Well I have the following reasons not to like the current python way:
> 
> 1) Beginning all your private variables with an underscore is like
> starting all your integers with an 'i' or all your dictionary with
> a 'd' etc.
> 
Well, surely anyone who's ever used Fortran knows that god is real 
unless explicitly declared to be integer. The convention wasn't meant 
for people who can't be safely allowed outside on their own.

> 2) The editor and font I use make it hard to see underscores. They
> usually seem to belong more to the line below than to the actual
> lines.
> 
So use a different editor and/or font, for Pete's sake.

> My idea as somekind of compromise between what happens in languages
> like C++ and currently in python would be the following:
> 
> 1) Allow keywords like private (or implemetation) to mark certain
> variables, functions or classes as an implementation detail.
> Personnally I would prefer the opposite such as a interface
> to mark objects which are not private, but that would break too
> much code.
> 
> 2) Allow the client access to these private variables, through
> a special construct. Maybe instead of "from ... import ..."
> "from ... spy ...".
> 
> Just an idea.
> 
Just an off-hand rejection.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list