Mirco Wahab wrote: > Thus spoke MRAB (on 2006-09-30 20:54): > >>Antoine De Groote wrote: >> >>>I just have to learn accept the fact that Python is more verbose more >>>often than Ruby (I don't know Perl really). >> >>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. > > > This statement reduces to the fact, that > > - in Python you keep the matches if you want, > but drop them if you don't > > import re > text = "this is 5 some 89 stuff 12 with numbers 21 interspersed" > matches = re.split('\D+', text) > > - in Perl you keep the matches if you want, > but drop them if you don't > > $text = "this is 5 some 89 stuff 12 with numbers 21 interspersed"; > @matches = $text=~/(\d+)/g; > > I fail to see the benefit of a re-object, I consider these to > be just there because regexes aren't in the core language. > Fine. Just because you fail to see the benefit, however, that doesn't mean there isn't one. Maybe we just aren't explaining it in terms you can appreciate?
regards Stve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list