is Python fully object oriented ?

Ben Hutchison benh at intelligenesis.net
Fri Jan 12 01:13:09 EST 2001


I detect a strong whiff of advocacy, but thank you for replying in detail.

Jan Dries wrote:

> Ben Hutchison wrote:
> > 1. Most significantly, Python requires the "self" or "this" reference to be
> > explicitly declared. This seems like a bit of a hassle if you do pure OO
> > development with python; lots of typing!
>
> This is a design choice (the "explicit is better than implicit", one of
> Python's favourite design choices), and as any design choice, a
> compromise.

I'd like to see some primary evidence of this "design choice" process, describing
the motivating reasons. Presumably there are some web references somewhere. My
instinct tell me it resembles an implementation consequence, rather than a free and
deliberate choice.

> About a year
> ago, I discovered Python and have since then written thousands of lines
> of Python code, yet have not once experienced the typing of "self." to
> be overhead,

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.

> > 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.

>
> > * Can a class declare a priviledged API availalbe only to subclasses?
>
> Here you refer to the notion of protected members.

Id agree the benefit of protected members is dubious. I wont bother contest this
one.

>
> 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.

Ben

--
Ben Hutchison
Software Engineer-Market Predictor
Webmind Australia
http://www.webmind.com/productspredictor.html






More information about the Python-list mailing list