Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74359
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <fomcl@yahoo.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.061 |
| X-Spam-Evidence | '*H*': 0.88; '*S*': 0.00; '"("': 0.09; 'append': 0.09; 'friday,': 0.09; 'integers': 0.09; 'iterate': 0.09; 'literal': 0.09; 'skip:\\ 10': 0.09; 'subject:How': 0.10; '")"': 0.16; '-tkc': 0.16; 'although,': 0.16; 'bracket': 0.16; 'means.': 0.16; 'roy': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'utterly': 0.16; 'wrote:': 0.18; 'thu,': 0.19; '>>>': 0.22; 'example': 0.22; 'to:name:python-list@python.org': 0.22; 'header:Received:8': 0.24; 'sort': 0.25; 'shown': 0.26; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'tim': 0.29; 'characters': 0.30; 'chase': 0.31; "d'aprano": 0.31; 'steven': 0.31; '-----': 0.33; 'comment': 0.34; 'subject:the': 0.34; 'but': 0.35; 'two': 0.37; 'list': 0.37; 'email addr:python.org': 0.37; 'awesome': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'subject:': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'expression': 0.60; 'received:98.137': 0.60; 'first': 0.61; 're:': 0.63; 'july': 0.63; 'skip:n 10': 0.64; 'more': 0.64; 'email name:python-list': 0.65; 'close': 0.67; 'header:Reply-To:1': 0.67; 'received:gq1.yahoo.com': 0.68; 'received:mail.gq1.yahoo.com': 0.68; 'smith': 0.68; 'useful.': 0.68; 'received:98.136': 0.69; 'jul': 0.74; 'article': 0.77; 'as:': 0.81; 'commenting': 0.84; 'received:bullet.mail.gq1.yahoo.com': 0.84; 'skip:: 20': 0.84; 'capture': 0.91 |
| X-Yahoo-Newman-Property | ymail-4 |
| X-Yahoo-Newman-Id | 79043.32115.bm@omp1018.mail.gq1.yahoo.com |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1405091890; bh=B1mp0oWr+tt2wuOc35vb7puGSEVpr5Em0Gl7ixzisX8=; h=References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=xBgXWywod+pWkSuZgZERAzRTTRoSSZVozugXIXD/eH9lH5RQyDOen4a0yM9em3/qbdQZEeU69o5FLv01jTtita/fuKP/H0Y/axIbniTBuCRrWrjlbBz5kYJAlYFcAhFfzXjJzPEFSBsWjUuYbpd2dSVfyVjSJ/ymVva9KCJYl3Y= |
| X-YMail-OSG | pp6jgZIVM1kUiQsCxwkbS7y8dqH26wsN6lxVPGQJljeUNHV R6oizoAIlaHQSyY.0n0g6IgwdwRuXEHqzG49ExRZnIHH2GAk8BMbBAn9AMv8 Yr8cNmt4h3sKRZkD1s11TRuiSM3pWY1VVKlDmg00Zd6Mz38F5s6BWE2.koQ6 Sgo0R4OjtHDXXs5O8W9PpGCwz7Rfgq3GKuB.fOzLqdTFU4_8uCmWZr6npYrW Y2EAUwxcz7AF8T8Wg8bwXhg68dA_Q7Po5ZPJGJ1GtFr1Jz3G7VzkFe1Qdi1i G3PlbiQhZPd_ZdMhIkhEe9Xdm8ruUXrNxU0gwPvXA3IZnwUEZrn2lptBjzaW s3JQSyqFX_XfGLcSIAEodR1NqkRkP4ZKhDfNpgKRnNodxXM.z9_Bo3vvOzPd nd8PBU5gxL3UejjCk7YUBhEDxc.kc1F_T_qR7duZ.1x92xQpvsTpfCIDK1p0 V0rIdQr5ToNgXEF02aekmOmxcUtm6EK4utKm6LQ2spi6noUa0OttjVp3OWc7 87jjQR2wt7gYFvySuQafwArNHthjwAB46Mwq59vnQS5CTaIBvs_0XSX4.qxo - |
| X-Rocket-MIMEInfo | 002.001, CgotLS0tLSBPcmlnaW5hbCBNZXNzYWdlIC0tLS0tCgo.IEZyb206IFN0ZXZlbiBEJ0FwcmFubyA8c3RldmVAcGVhcndvb2QuaW5mbz4KPiBUbzogcHl0aG9uLWxpc3RAcHl0aG9uLm9yZwo.IENjOiAKPiBTZW50OiBGcmlkYXksIEp1bHkgMTEsIDIwMTQgMTE6MDQgQU0KPiBTdWJqZWN0OiBSZTogSG93IHRvIGRlY2lwaGVyIDpyZS5zcGxpdChyIihcKFwoW14pXStcKVwpKSIgaW4gdGhlIGV4YW1wbGUKPiAKPiBPbiBUaHUsIDEwIEp1bCAyMDE0IDIzOjMzOjI3IC0wNDAwLCBSb3kgU21pdGggd3JvdGU6Cj4gCj4BMAEBAQE- |
| X-Mailer | YahooMailWebService/0.8.194.680 |
| References | <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> <mailman.11746.1405042179.18130.python-list@python.org> <roy-CC0052.22182710072014@news.panix.com> <mailman.11747.1405046292.18130.python-list@python.org> <roy-AAB0F1.23332710072014@news.panix.com> <53bfa881$0$2746$c3e8da3$76491128@news.astraweb.com> |
| Date | Fri, 11 Jul 2014 08:18:09 -0700 |
| From | Albert-Jan Roskam <fomcl@yahoo.com> |
| Subject | Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example |
| To | Steven D'Aprano <steve@pearwood.info>, "python-list@python.org" <python-list@python.org> |
| In-Reply-To | <53bfa881$0$2746$c3e8da3$76491128@news.astraweb.com> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | Albert-Jan Roskam <fomcl@yahoo.com> |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.11761.1405092218.18130.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1405092218 news.xs4all.nl 2912 [2001:888:2000:d::a6]:52835 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:74359 |
Show key headers only | View raw
----- Original Message -----
> From: Steven D'Aprano <steve@pearwood.info>
> To: python-list@python.org
> Cc:
> Sent: Friday, July 11, 2014 11:04 AM
> Subject: Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example
>
> On Thu, 10 Jul 2014 23:33:27 -0400, Roy Smith wrote:
>
>> In article <mailman.11747.1405046292.18130.python-list@python.org>,
>> Tim Chase <python.list@tim.thechases.com> wrote:
>>
>>> On 2014-07-10 22:18, Roy Smith wrote:
>>> > > Outside this are \( and \): these are literal opening
> and closing
>>> > > bracket characters. So:
>>> > >
>>> > > \(\([^)]+\)\)
>>> >
>>> > although, even better would be to use to utterly awesome
>>> >> re.VERBOSE
>>> > flag, and write it as:
>>> >
>>> > \({2} [^)]+ \){2}
>>>
>>> Or heck, use a multi-line verbose expression and comment it for
>>> clarity:
>>>
>>> r = re.compile(r"""
>>> ( # begin a capture group
>>> \({2} # two literal "(" characters [^)]+
> # one or more
>>> non-close-paren characters \){2} # two literal
> ")"
>>> characters
>>> ) # close the capture group """,
> re.VERBOSE)
>>>
>>> -tkc
>>
>> Ugh. That reminds me of the classic commenting anti-pattern:
>
> The sort of dead-simple commenting shown below is not just harmless but
> can be *critically important* for beginners, who otherwise may not know
> what "l = []" means.
>
>> l = [] # create an empty list
>> for i in range(10): # iterate over the first 10 integers
>> l.append(i) # append each one to the list
>
Anything better than this hideous type of commenting: (?#...), e.g
>>> re.match("(19|20)[0-9]{2}(?#year)-[0-9]{2}(?#month)", "2010-12")
Same thing for the 'limsux' modifiers, although *maybe* they can be useful.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
How to decipher :re.split(r"(\(\([^)]+\)\))" in the example fl <rxjwg98@gmail.com> - 2014-07-10 08:37 -0700
Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Peter Otten <__peter__@web.de> - 2014-07-10 18:49 +0200
Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example MRAB <python@mrabarnett.plus.com> - 2014-07-10 18:01 +0100
Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Joel Goldstick <joel.goldstick@gmail.com> - 2014-07-10 13:05 -0400
Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Albert-Jan Roskam <fomcl@yahoo.com> - 2014-07-10 12:15 -0700
Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Cameron Simpson <cs@zip.com.au> - 2014-07-11 11:29 +1000
Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Roy Smith <roy@panix.com> - 2014-07-10 22:18 -0400
Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Tim Chase <python.list@tim.thechases.com> - 2014-07-10 21:37 -0500
Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Roy Smith <roy@panix.com> - 2014-07-10 23:33 -0400
Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Chris Angelico <rosuav@gmail.com> - 2014-07-11 14:31 +1000
Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example alister <alister.nospam.ware@ntlworld.com> - 2014-07-11 08:00 +0000
Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Steven D'Aprano <steve@pearwood.info> - 2014-07-11 09:04 +0000
Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Albert-Jan Roskam <fomcl@yahoo.com> - 2014-07-11 08:18 -0700
csiph-web