is python Object oriented??
clp2 at rebertia.com
Sun Feb 1 13:53:20 CET 2009
On Sat, Jan 31, 2009 at 9:08 AM, <thmpsn.m.k at gmail.com> wrote:
> On Jan 30, 12:15 am, Chris Rebert <c... at rebertia.com> wrote:
>> - Python supports encapsulation. Prefixing an attribute/method with an
>> underscore indicates that other programmers should treat it as
>> 'private'. However, unlike B&D languages, Python itself does nothing
>> to enforce this privacy, leaving it instead to the good judgement of
>> the programmer, under the philosophy that "We're all consenting adults
> How do you know? (I know I'm not.)
> Seriously, though, the lack of private members does allow for ugly
> hacks in user code, and you know there are always ugly hackers.
Marc already addressed your points excellently, but I'll add that I
once read somewhere (can't be bothered to find the source, PG maybe?)
that mediocre programming languages are designed for average
programmers and presume the language designers are smarter than the
programmer, whereas the truly great languages are designed for great
programmers and presume that the programmer is smarter than (or at
least knows better than) the designer.
This allows smart programmers using great languages to say: "I don't
like X about the language, I think I'll change it" or "The language
needs Y, I'll add it". For example, see the amazing magic some Python
people have worked using metaclasses.
Whereas smart programmers using a mediocre language are stuck: "I
don't like X about the language and there's nothing I can do about it
short of hacking the language implementation. Darn. Now I'm going to
have to write Y lines every time I want to workaround X since the
language doesn't let me factor the solution out any further! (sigh)".
For example, consider looping through an array in Java before the new
'for' statement was added.
Therefore, Python wisely chooses to not give a damn about how "ugly
hackers" may abuse the language; they'll abuse *any* language they get
their grubby mitts on; just let them and their ugly code quietly rot
in the corner while the elite are allowed by the language the extra
leeway they need to write their code masterpieces, which the common
people can then use to improve their programs.
Not that I'm saying any of us are necessarily elite; just don't be
/particularly/ stupid by using anything *clearly marked* with an
initial underscore without *extremely* good reason. And this isn't to
say the language shouldn't take average programmers into account; just
don't overly restrict the the 90% that are decent programmers in the
name of trying to save the bottom 10% from themselves (it's rather
like the "Save the Children!" retort on /.)
Follow the path of the Iguana...
More information about the Python-list