Python evangelists unite!

brucehapman at hotmail.com brucehapman at hotmail.com
Thu Nov 29 17:28:40 EST 2001


Okay, I was extolling the benefits of Python to a friend of mine. He
took strong exception to Python's OO model. <here we go again...>

     ME: Python's great--you can add members to instances OR classes
on-the-fly!
 FRIEND: Why would you want to do that? 
     ME: Uh...
 FRIEND: Besides, that's awful Object Orientation. If I start adding
attributes to an instance of a class, it ceases to be an instance of
that class. If I create a bunch of instances of the same class, they
should be the same; they should have the same members.
     ME: Yeah, but with dynamicism, I can add a new pane to a GUI
while it's running. I just change an instance to include a new pane,
and...
 FRIEND: That's pretty cool, but it's not a reason, in and of itself,
to make a language so dynamic. There must be some advantage to being
able to add attributes during runtime. What are they?
     ME: Uh...
 FRIEND: And another thing! What's with encapsulation? There's no
private!?!?!?
     ME: <Screaming and running for cover>

So, I need some help. I've checked out c.l.p and some on-line
articles, and I just can't find good practicle examples of a program
that adds members to instances (or classes) at runtime. Anybody got
any? I don't want to have to start avoiding my friend....

TIA,
b.



More information about the Python-list mailing list