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

Tom Robinson tom at alkali.spamfree.org
Tue Aug 7 06:08:14 EDT 2001


On Tue, 7 Aug 2001 10:01:24 +0200, "Alex Martelli" <aleaxit at yahoo.com>
wrote:

>"Phil Tomson" <ptkwt at shell1.aracnet.com> wrote in message
>news:X2Jb7.24637$C7.9671673 at e3500-chi1.usenetserver.com...
>    ...
>> Questions for the Ruby community to ponder: What sorts of features do we
>> need that might be unique to Ruby?  [One that comes to mind: the ability
>> to extend an existing class.]  For the
>
>In what sense is this "unique to Ruby"?  The following works in Python:

<code>

># and now you can call anInstance.two(), having
># extended existing class Existing "after the
># fact" -- already-created instances also get
># to use the 'extensions' to the class.

He might be talking about the way you can reopen and extend existing
_built_in_ classes in Ruby, for example:

class Regexp
  alias oldcomp =~
  def =~ (astring)
     match(astring)[1..9]
  end
end

...Regexp being part of the standard library.  Can you do this in
Python?  It would be nice...

-- 
tom at alkali.spamfree.org
remove 'spamfree.' to respond



More information about the Python-list mailing list