[BangPypers] Object Oriented Programming in python

Saager Mhatre saager.mhatre at gmail.com
Mon Oct 21 08:23:47 CEST 2013

On Oct 21, 2013 11:39 AM, "Dhananjay Nene" <dhananjay.nene at gmail.com> wrote:
> On Mon, Oct 21, 2013 at 10:55 AM, Saager Mhatre <saager.mhatre at gmail.com>
> > Which generally lead to poor (or at least poorer) abstractions; but I
> Leaky ??  :)

For the most part, yes.

> >
> >> I think OOPs concepts across a number of languages are quite different.
> >> You will find python having superior constructs eg. metaclasses etc.
if you were comparing Python OOP to C++/Java.
> >
> > Superior constructs implemented inferiorly. Meteclasses are much^3 more
powerful in Groovy, Ruby and SmallTalk (where some would claim Python
borrowed them from; but that's just not true.)
> I wonder if you meant syntactically/stylistically. Would be keen to
learn, if there are examples where ruby / groovy (I don't know much about
smalltalk) allow things that python does not.

Semantically! MetaClasses are a much more powerful construct in those
languages. They form the core of the MetaObjectProtocol which governs the
dynamic dispatch of messages/methods. Modifications to MetaClasses
percolate to Classes and objects they are associated with and such
modifications as well as MetaClass associations can be dynamic as well as
temporary; leading to some seriously powerful use cases.

That's pretty much what always foiled my attempts at understanding Python
MetaClasses, I was looking for power where there was none to find. The best
comparison I could find was to Groovy's Compile time AST transforms, but
even those are even more powerful as they drop down a level of abstraction
and hand you the AST for the an rated element.

- d

More information about the BangPypers mailing list