Python evangelists unite!
Fernando PĂ©rez
fperez528 at yahoo.com
Wed Nov 28 12:57:46 EST 2001
brucehapman at hotmail.com wrote:
> 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...>
>
[snip]
>
> 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....
>
I am currently working on a replacement for the python interpreter
which depends *critically* on this. It allows the user to define
special commands to control the interpreter and access the underlying
shell on the fly, and this requires dynamical generation of method
code (via exec with fancy tricks with string formatting) and then
binding those methods on the fly to the currently running
interpreter. Obviously you can do that in C with a heinous mess of
pointer tables, but the point is, having those features available to
me is the difference between actually producing the program vs.
saying 'Obviously you can do that in C with a heinous mess of pointer
tables' and never actually doing it (because it's so ugly and tricky).
I'm playing tons of strange tricks with namespaces, code
introspection and dynamical changing of running code. I can't even
begin to imagine how I would do some of those things in any language
other than Python (yes, I don't know Lisp. Shoot me.)
Cheers,
f.
ps. If curious, I think I'll announce the first beta of this around
next week. It's almost ready.
More information about the Python-list
mailing list