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

Rich Harkins rharkins at thinkronize.com
Tue Aug 7 10:03:24 EDT 2001


Yeah, Python has a built-in regexp module.  I usually use something like:

workRE=re.compile('...')
def f(s):
	...
	workRE.search(s)
	...

Python doesn't have an implicit re operator like Perl or Ruby but I prefer
this.  RE in any language can be expensive if not done right and I like the
fact that I can't be cavalier about just tossing in another RE because it's
convenient.  Plus, in Python one can even pull a RE out of a module and test
it in the interactive interpreter, aiding in performance tuning.

Anyway, those are just my thoughts.  As others have said, your milage may
vary.

Rich


> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Tom Robinson
> Sent: Tuesday, August 07, 2001 6:08 AM
> To: python-list at python.org
> Subject: Re: Perl/Python/Ruby common backend (Parrot, can Ruby play
> too?)
>
>
> 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
> --
> http://mail.python.org/mailman/listinfo/python-list
>





More information about the Python-list mailing list