is python Object oriented??

Hung Vo hungvn94 at gmail.com
Fri Jan 30 20:35:09 EST 2009


On Fri, Jan 30, 2009 at 5:15 PM, Chris Rebert <clp2 at rebertia.com> wrote:

> On Thu, Jan 29, 2009 at 9:56 PM, Hung Vo <hungvn94 at gmail.com> wrote:
> <snip>
> > I'm new to Python and also wondering about OOP in Python.
> >
> > I want to justify the above question (is Python Object-Oriented?).
> > Does Python follow the concepts/practices of Encapsulation,
> > Polymorphism and Interface, which are quite familiar to Java
> > programmers?
>
> If you're looking for a benchmark for object-orientedness, Smalltalk,
> not Java, is the canonical language to compare against.


I was introduced to OOP via C++/Java, so its quite nature to compare and
contrast with the languages you know even they seem not to be original. I
definitely will learn about Smalltalk.


>
> Anyway, to your three-pronged question:
> - Yes, Python supports polymorphism. I find it hard to think of an
> example of an OO language that doesn't.
>
> - Python does not support interfaces in the Java sense (although there
> are a few third-party libraries that add such support); neither does
> Smalltalk. Instead, both Smalltalk and Python use duck-typing to
> similar effect. See http://en.wikipedia.org/wiki/Duck_typing


Its seem to me that duck typing is a special case of static vs dynamic type
debate and clearly Python is a dynamic type philoshopy's follower.

>
> - 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
> here". This allows people to meddle with internals, at their own risk,
> if it ends up being absolutely necessary. The enforcement point is
> largely academic anyway, as most languages' reflection APIs let you
> poke at ostensibly "private" things.


I like the flexibility of not being enforced to the encapsulation rules,
however, you're right, we do at our own risk and have to tradeoff the
flexibility with the secure a static type system like Java provides.

P.S. You appear to have posted the same message 3 times(!), which is a
> bit annoying for readers.


sorry for this annoyance. I dont know why a new post was made whenever i
cliked on the topic link. Probably, there's something wrong with google
group. on investigating...

>
> --
> Follow the path of the Iguana...
> http://rebertia.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090131/4932d3c4/attachment-0001.html>


More information about the Python-list mailing list