Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; 'ascii': 0.07; 'class,': 0.07; 'escape': 0.07; 'function,': 0.07; 'python': 0.09; 'subject:characters': 0.09; 'subject:string': 0.09; 'cc:addr :python-list': 0.10; 'language': 0.14; 'keyword.': 0.16; 'language?': 0.16; 'string': 0.17; 'wrote:': 0.17; 'versions': 0.20; 'trying': 0.21; 'error.': 0.21; 'sorry,': 0.22; 'seems': 0.23; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'am,': 0.27; 'cc:addr:gmail.com': 0.27; 'lines': 0.28; 'str': 0.29; 'version': 0.34; 'except': 0.36; 'but': 0.36; 'characters': 0.36; 'method': 0.36; 'should': 0.36; 'subject:: ': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'containing': 0.61; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'received:74.208.4.194': 0.84; 'angel': 0.93 Date: Tue, 09 Oct 2012 10:34:30 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: d@davea.name Subject: Re: string contains and special characters References: <5074336E.9050404@davea.name> In-Reply-To: <5074336E.9050404@davea.name> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:gvQL7scwF1vIrA/hfCikQEG+isdlQYMSu3kO8IIJKcz D24XR2kbBhK4kmBbV7zNHrrd8GtAmcuy6H+82WkocQ3mTNOlg0 Z5lJJboFcq4e4PbHNFA2QGpxXJzLcYL58KLLQUucFvQipc4bsA MBEJDjnG+RVGLMTg9lkMwOnVEmadsY4oGqb7JMuCicgRyZxtWd I2elCpoB1sAAgKN3638AvzetKYtDO2nC0HXrdVv9mgacjwqa+Q 4pXZ13ZwYiM5GBwau1selaeaoqdg9t10EbwuqmIqDuxiD07N8W xD+E3XTIQrJFAtHNONDXFPMjwRQY3aN50X9qk0slUTIPJHoeQ= = Cc: python-list@python.org, loial X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1349793304 news.xs4all.nl 6941 [2001:888:2000:d::a6]:57786 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31032 On 10/09/2012 10:23 AM, Dave Angel wrote: > On 10/09/2012 10:02 AM, loial wrote: >> I am trying to match a string that containing the "<" and ">" characters, using the string contains function, but it never seems to find the lines containing the string >> >> e.g if mystring.contains("") : >> >> Do I need to escape the characters...and if so how? >> > What language are you trying to use, and what version of that language? > In all the Python versions I know of, that line would simply be a syntax Sorry, I should have said "Attribute" error. > error. There's no "contains" method in the str class, use the 'in' keyword. > > if "' in mystring: > > No need to escape any ASCII characters except backslash. > -- DaveA