Python dynamic attribute creation

Michael Torrie torriem at gmail.com
Mon Jun 28 15:47:36 EDT 2010


On 06/25/2010 09:39 PM, WANG Cong wrote:
> Thanks, I have to admit that I know nothing about Smalltalk.

If you know nothing about Smalltalk then you really aren't in a position
to talk about what is and is not OOP.  Smalltalk is one of the original
OOP languages and purists define OOP as the model that Smalltalk
implemented.  In many ways Python is like Smalltalk.  Certainly it's
more like Smalltalk than Java or C++.  Although Python has a few pieces
of syntactic sugar that aren't truly OO, Python is much more OO than C++
or Java, for the reasons that others have already posted.

Some of your "doubts" concerning Python and OOP stem directly from your
exposure to Java and C++'s paradigms

> Hmm, although this is off-topic, I am interested in this too. C++ does
> have metaprogramming, but that is actually static metaprogramming (using
> templates), not dynamic metaprogramming here. I am wondering if
> efficiency is the only reason why C++ doesn't have dynamic
> metaprogramming, since C++ is a static programming language I think if
> this limits C++ to implement its dynamic metaprogramming actually...

I don't think C++ has any syntactic support for dynamic metaprogramming,
but I did read an article in Doctor Dobb's Journal that talked about
dynamic inheritance in C++.  The Boost library provides some static
metaprogramming facilities for C++.



More information about the Python-list mailing list