Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] What is the most appropriate scripting language
- Date: Wed, 17 Jan 2007 14:59:39 +0900
- From: "Stephen J. Turnbull" <stephen@example.com>
- Subject: Re: [tlug] What is the most appropriate scripting language
- References: <45AAFDA9.90504@example.com> <45AB4287.3070203@example.com> <3156339d0701152057u436f1122u82c2dbcd8aad9367@example.com> <87vej7cmw2.fsf@example.com> <3156339d0701161825y75fec769w6055610ba5878706@example.com>
Ian MacLean writes: > exactly : > > import re > p = re.compile('[a-z]+') > if p.match("some text"): > do_somthing() > > in python vs : > > if ( "some text" =~ /[a-z]+/ ) { > do_somthing(); > } > in perl. That's not quite right. The equivalent Python would be if match ('[a-z]+', 'some text'): do_somthing () (it's unfair to burden the Python idiom with the import statement; that's once per module overhead). What you can't do with Python "match" that you can do with Perl "=~" is to access match contents. To be pedantic, this is less an issue with Python regexps than with Guido's dislike for assignment expressions. (He's even on record as saying that introducing the "+=" idiom was a mistake!) If he'd back down on that, then you could do if (m = match ('[a-z]+', 'some text')): do_somthing (m) which isn't bad at all. In fact, after many years of writing (more usually, forgetting to write) stuff like (progn (re-search-forward "[a-z]+") (save-match-data ;; an easy-to-forget PITA ;; especially if hidden in somebody ;; else's code! (re-search-forward "[0-9]+") (insert (match-string 0))) (insert (match-string 0))) I've come to the conclusion that I *want* explicit match objects. YMMV, of course.
- References:
- [tlug] What is the most appropriate scripting language
- From: Dave M G
- Re: [tlug] What is the most appropriate scripting language
- From: Walter Hansen
- Re: [tlug] What is the most appropriate scripting language
- From: Ian MacLean
- Re: [tlug] What is the most appropriate scripting language
- From: Stephen J. Turnbull
- Re: [tlug] What is the most appropriate scripting language
- From: Ian MacLean
Home | Main Index | Thread Index
- Prev by Date: Unicode support in classic Unix programs including Python. . . . . . . . . (was: Re: Learn a Variety of Languages) [tlug]
- Next by Date: Re: Bourne Shell is the most appropriate scripting language (was Re: [tlug] What is the most appropriate scripting language)
- Previous by thread: Re: [tlug] What is the most appropriate scripting language
- Next by thread: Re: [tlug] What is the most appropriate scripting language
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links