is Python fully object oriented ?

Issac Trotts trotts at mit.edu
Fri Jan 12 02:09:42 EST 2001


> Im sure you grow used to it, but Im not convinced its preferable. My general
> preference, shared by many programmers I suggest, is that extraneous code be
> minimized. That also seems to be a theme in pythons design, I notice. Its perfectly
> legal to explictly use "this" everywhere in C++/Java if you like it that way, you
> just arent forced to.

I don't know if this helps, but it's perfectly legal to use a name other
than "self" in Python, e.g.,

class SpamChunk:
  def __init__(s):
    s.color = 'green'

> > > 2. Access control is more informal in Python than C++/Java. I know in the case
> > > of Java at least that security provisions depend in part on access control
> > > being strictly enforced, and additonally there are a number of design
> > > principles that assume 3 tiered (public, protected, private) access levels.
> > > * Is Pythons leading underscore mechanism more of a convention?
> >
> > > * It is strong enough to build security mechanisms on?
> >
> > Even the C++ support for public/protected/private access is not strong
> > enough to enforce security. <snip>
> 
> In other words, no. However, Java's is. private members really are very private, and
> this gives the programmer design options not available perhaps in Python. IMO, cases
> where you simply cant do something, by any technique, in a language, are ones to
> watch out for. Possibly python could benefit from a strong private modifier.

Even if Python would be better off with a strong private modifier
(which I think would be draconian), it's never going to be a matter
of "simply can't" because one can always write a C extension to
work around the privacy.

> > The bottom line, IMO, is that Python has managed here (as with so many
> > other aspects of the language) to provide a very simple approach that at
> > least in practice is just as effective as the equivalent C++ or Java
> > feature,
> 
> Except security. And in some domains, where you have someone elses untrusted code
> executing, that really does matter. Python can prevent accidental access to private
> fields but not a deliberate attempt. When people consider building very large
> systems from python, they surely will encounter this barrier. It may prevent pythons
> use where it would otherwise be appropriate.

Come to think of it, what would prevent someone from writing a
C extension that violates access control in a Java program?

Issac





More information about the Python-list mailing list