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

Paul Rubin http
Tue Oct 4 20:48:44 EDT 2005


"El Pitonero" <pitonero at gmail.com> writes:
> If so, you would probably be the type of person that also likes static
> typing, type safety and variable declaration, right?

I certainly want type safety, which Python claims to have.  I'd like
to have variable declaration, at least like "var x".  Perl has that
("use strict") and Perl is often compared to Python, so I don't see
why Python shouldn't offer it.  

I reserve judgement about static typing.  It has good and bad points.
I find Python and Lisp much more pleasant to program in than (say)
Java, but I'm not convinced it's because they are dynamically typed.
It may be mostly because they have better built-in datatypes.  I've
been wanting to try ML or Haskell and see how that goes.  Note that ML
is statically typed but doesn't need declarations (it uses
compile-time type inference).

> You missed the point. I have, for fun, built a GUI application in
> Python, while the program is running. I just kept on adding more and
> more code to it. This, while the Python program is running. I was able
> to change the GUI's look-and-feel, add more buttons, menus, all while
> the programming is running.

Sure, the GUI is a container that can support those operations.  That
has not much to do with whteher the language is dynamic.

> I was able to change the class definition, preserve the previous
> object state variables. 

Unconclusive.  You can even do stuff like that in C under a debugger.

> Sure, Python is not as friendly as Lisp/Scheme for interactive
> programming, but you can still do a lot.

But Lisp supports declarations and compile-time type analysis of the
exact same kind that you want kept away from Python.

> > [Other stuff incomprehensible and snipped].
> Sigh, I gave you the keywords: containment and aggregation.
> 
> Vault encapsulation is one way to do OOP. But by no means it is the
> only way. The whole access level thing (the "private" keyword) is not
> an essential part of OOP. The concept of a "private" namespace is not
> necessary for OOP. 

Not necessary or essential, but useful, and improves your program's
reliability.  It's a tool for protecting complex systems against
certain failures, like using a network firewall on your computer.
Sure, you don't really need the firewall, in the sense that your
applications should be careful about what ports they listen to, but
with enough code running on the machine you can't really be certain
that nothing is broken, so it's standard practice to use a firewall
and shut off any ports not needed by some specific service.  A private
variable is like shutting off a port at the firewall instead of
relying on the user apps to to handle it safely--a completely normal
and sensible procedure in any complex environment.




More information about the Python-list mailing list