Perl/Python/Ruby common backend (Parrot, can Ruby play too?)

Erno Kuusela erno-news at
Wed Aug 8 01:36:28 CEST 2001

In article <9kpeft$kbm$1 at>, "Andrew Dalke"
<dalke at> writes:

| She chose Tcl (with an
| object extension) over Python because Python's ability to add
| new methods is not obvious[*] and because existing instances
| are not updated with the new class definitions

you can do this:

>>> class Spam:
...     def eat(self):
...         print 'yum'
>>> spam = Spam()
>>> def new_eat(self):
...     print 'yech'
>>> = new_eat

if you want it to attach the new method to the same class in face of
inheritance, you need " = new_eat" - you could
wrap it in a function if that look too much like a magic incanatation
for your audience.

if you actually want to replace the underlying classes of all
instances, you could probably cook something up with the weakref
module and calling a registration function in __init__...

  -- erno

More information about the Python-list mailing list