Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'attribute': 0.05; 'method.': 0.05; 'preferably': 0.05; 'escape': 0.07; 'function,': 0.07; 'subject:characters': 0.09; 'subject:string': 0.09; '(something': 0.16; 'getting,': 0.16; 'jerry': 0.16; 'oct': 0.16; 'reproduce': 0.16; 'string': 0.17; 'wrote:': 0.17; 'string,': 0.17; 'trying': 0.21; 'assuming': 0.22; 'seems': 0.23; 'header:In- Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'lines': 0.28; 'error': 0.30; 'code': 0.31; 'received:209.85.160.46': 0.32; 'getting': 0.33; 'to:addr:python- list': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'wrong': 0.34; 'received:209.85': 0.35; 'but': 0.36; 'should': 0.36; 'enough': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'your': 0.60; 'containing': 0.61; 'telling': 0.61; "you'll": 0.62; 'solve': 0.62; 'provide': 0.62; 'seeing,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=DDq/O2hSWP6oAzX0x0Ln5l+RFxOIVFhAuU443PgJ5Aw=; b=Bcd1Ng4m/DJGcNEpa5Y+hbm7OvT8Y+3BMjWTjcsfChpiGuV7ZKKAojJRfQZFmfSsY4 9mJvTo22eQzzaOaAIt078kdWrskkLf7yG+4NB5FWBDKs0dxGxMADeno07j6fy9dOMzit 5T4qJQf5+yrF4puAPvjQfxL0HVkY50EiS2xoRb/kntU/pGe0RV0vSAGgyGgqkndHfaUL 2Povy6hGif9g2mrXox8KIl3rdiF/ADAaGiWu0ZWX7DK6+fgcKlwJabP3001WLOBN4Wf6 KvdO1sLZnlF1IP3FFE3My+mfZSe3gJhToYzvtBRv2ySYNn/Ccr/J1k7yTr2MB8PnrLIb nsSQ== MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 9 Oct 2012 10:34:17 -0400 Subject: Re: string contains and special characters From: Jerry Hill To: python-list@python.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1349793260 news.xs4all.nl 6967 [2001:888:2000:d::a6]:57287 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31031 On Tue, Oct 9, 2012 at 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? Strings don't have a contains() method. Assuming that mystring is actually a string, you should be getting a very specific error, telling you exactly what's wrong with your code (something like AttributeError: 'str' object has no attribute 'contains'). If that isn't what you're seeing, you'll need to provide the full and complete text of the error you are getting, and preferably enough of your code that we can reproduce the issue and help you solve it. -- Jerry