builtin regular expressions?
google at mrabarnett.plus.com
Sat Sep 30 20:54:40 CEST 2006
Antoine De Groote wrote:
> Just to get it clear at the beginning, I started this thread. I'm not a
> newbie (don't get me wrong, I don't see this as an insult whatsoever,
> after all, you couldn't know, and I appreciate it being so nice to
> newbies anyway). I'm not an expert either, but I'm quite comfortable
> with the language by now. It's just that, when I started Python I loved
> it for its simplicity and for the small amount of code it takes to get
> something done. So the idea behind my original post was that the
> Perl/Ruby way takes even less to type (for the regex topic of this
> discussion, I'm not generalizing), and that I like a lot. To me (and I
> may be alone) the Perl/Ruby way is more "beautiful" (Python culture:
> Beautiful is better than ugly) than the Python way (in this particular
> case) and therefore I couldn't see the reasons.
> Some of you say that this regex stuff is used rarely enough so that
> being verbose (and therefore more readable ?) is in these few cases the
> better choice. To me this a perfectly reasonable and maybe it is just
> true (as far as one can talk about true/false for something subjective
> as this). I dont' know (yet) ;-)
> I just have to learn accept the fact that Python is more verbose more
> often than Ruby (I don't know Perl really). Don't get me wrong though, I
> know the benefits of this (at least in some cases) and I can understand
> that one opts for it. Hopefully I will end up some day preferring the
> Python way.
One of the differences between the Python way and the Perl way is that
the Perl way has a side-effect: Perl assigns to the variables $1, $2,
etc. each time you execute a regular expression whereas Python just
returns a match object for each, so it's not overwriting the results of
the previous one. I find the Python way cleaner.
More information about the Python-list