Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6556

Re: Weird problem matching with REs

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'predefined': 0.05; 'string,': 0.05; 'python': 0.08; 'backslash': 0.09; 'object.': 0.09; 'syntax': 0.11; 'am,': 0.14; 'received:209.85.214.174': 0.14; 'received:mail-iw0-f174.google.com': 0.14; 'wrote:': 0.14; '(via': 0.16; 'angelico': 0.16; 'apostrophe': 0.16; 'delimit': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'mon,': 0.17; 'slightly': 0.19; 'header:In-Reply-To:1': 0.21; 'variable': 0.21; 'file,': 0.22; 'subject:problem': 0.22; 'code.': 0.22; 'issues.': 0.23; 'appear': 0.23; 'xml': 0.26; 'string': 0.26; 'object': 0.26; 'message-id:@mail.gmail.com': 0.28; 'closing': 0.28; 'received:209.85.214': 0.28; 'config': 0.30; 'equivalent': 0.31; 'andrew': 0.32; 'to:addr:python-list': 0.33; 'chris': 0.34; 'source': 0.34; 'file': 0.34; 'skip:" 10': 0.35; 'else': 0.35; 'difference': 0.37; 'received:google.com': 0.37; 'something': 0.37; 'change': 0.37; 'received:209.85': 0.37; 'another': 0.37; 'run': 0.38; 'worry': 0.38; 'subject:: ': 0.38; 'received:209': 0.39; 'containing': 0.39; 'subject:with': 0.39; 'to:addr:python.org': 0.39; 'your': 0.60; '30,': 0.84; 'composing': 0.84; 'grabbing': 0.84; 'tag,': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=V49IyItcRNvKwgp1XZyXXXMDgC0y5MFP2DsVTv1YznE=; b=vrofQsBP+o0Fj4GLYvmwROTPx++LCQ04KenlMkegSdKyLOpTdQWk3Sh5oveMNEKiVC nif+SZJ3QevCJxKcp2dq4s4kzma64n/XTlHX74nsiU//7iiX/mz1WgBF5fUxUD0ZIEdT 8gnHmhf/arPTvVD6+JgYDGGIYe6L5nbY2mv18=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=mBGje1YPuB8IlHBfhdJVVEIR+VvclNjk0RBazBtc939hPQZbZJUL4drbRMn1c1vlWc YA4PSooTSLe6fVN2DVEhz5B0BTw45EQtq1C5SNDb+yhdnVt1p2c5av0cC4ZL8kvhnuUT lq/67wUi7QuHomoSR1RMDRKjPcoVvuEDUwrJI=
MIME-Version 1.0
In-Reply-To <4DE27163.3080104@gmail.com>
References <mailman.2220.1306669538.9059.python-list@python.org> <4de2459b$0$29996$c3e8da3$5496439d@news.astraweb.com> <mailman.2222.1306676482.9059.python-list@python.org> <4de255a8$0$29996$c3e8da3$5496439d@news.astraweb.com> <mailman.2223.1306679725.9059.python-list@python.org> <1b8d81c1-ab87-4059-ad55-9f4a39331e7d@u26g2000vby.googlegroups.com> <4DE27163.3080104@gmail.com>
Date Mon, 30 May 2011 03:57:38 +1000
Subject Re: Weird problem matching with REs
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2230.1306691862.9059.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 82.94.164.166
X-Trace 1306691862 news.xs4all.nl 49182 [::ffff:82.94.164.166]:34084
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6556

Show key headers only | View raw


On Mon, May 30, 2011 at 2:16 AM, Andrew Berg <bahamutzero8825@gmail.com> wrote:
>> Also, be sure to
>> use a raw string when composing REs, so you don't run into backslash
>> issues.
> How would I do that when grabbing strings from a config file (via the
> configparser module)? Or rather, if I have a predefined variable
> containing a string, how do change it into a raw string?
>

"Raw string" is slightly inaccurate. The Python "raw string literal"
syntax is just another form of string literal:

'apostrophe-delimited string'
"quote-delimited string"
"""triple-quote string
which may
go over
multiple lines"""
'''triple-apostrophe string'''
r'raw apostrophe string'
r"raw quote string"

They're all equivalent once you have the string object. The only
difference is how they appear in your source code. If you read
something from a config file, you get a string object directly, and
you delimit it with something else (end of line, or XML closing tag,
or whatever), so you don't have to worry about string quotes.

Chris Angelico

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Weird problem matching with REs Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-29 06:45 -0500
  Re: Weird problem matching with REs Ben Finney <ben+python@benfinney.id.au> - 2011-05-29 23:00 +1000
    Re: Weird problem matching with REs Ben Finney <ben+python@benfinney.id.au> - 2011-05-29 23:03 +1000
    Re: Weird problem matching with REs Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-29 08:29 -0500
  Re: Weird problem matching with REs Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-29 13:09 +0000
    Re: Weird problem matching with REs Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-29 08:41 -0500
      Re: Weird problem matching with REs Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-29 14:18 +0000
        Re: Weird problem matching with REs Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-29 09:35 -0500
          Re: Weird problem matching with REs John S <jstrickler@gmail.com> - 2011-05-29 08:48 -0700
            Re: Weird problem matching with REs Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-29 11:16 -0500
              Re: Weird problem matching with REs John S <jstrickler@gmail.com> - 2011-05-29 09:45 -0700
            Re: Weird problem matching with REs Chris Angelico <rosuav@gmail.com> - 2011-05-30 03:57 +1000
      Re: Weird problem matching with REs Roy Smith <roy@panix.com> - 2011-05-29 11:19 -0400
        Re: Weird problem matching with REs Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-29 10:31 -0500
          Re: Weird problem matching with REs Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-29 21:06 +0200

csiph-web