Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'string.': 0.05; 'interpreter.': 0.07; 'skip:\\ 20': 0.07; 'string': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; "'\\\\'": 0.16; '11:59': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'literals.': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'replacing': 0.19; 'working.': 0.19; 'cc:addr:python.org': 0.22; 'interpret': 0.24; 'replace': 0.24; 'cc:2**0': 0.24; 'source': 0.25; 'header :In-Reply-To:1': 0.27; 'am,': 0.29; 'dec': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; '>>>>': 0.31; 'but': 0.35; 'received:google.com': 0.35; 'described': 0.36; 'method': 0.36; 'subject:?': 0.36; 'should': 0.36; 'so,': 0.37; 'that,': 0.38; "you're": 0.61; 'first': 0.61; "you'll": 0.62; 'anything.': 0.68; 'online': 0.71; 'to:none': 0.92; '2013': 0.98 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:cc :content-type; bh=ktdULO5yhyZLi3k+WtsNifOdHehXsK5Y/9/xentEA70=; b=TdFwlpl2k2pBAo7dvQ6+eLsGUCeb1ODcIVr3e4YeZGhCgmPUx9dFLptc1+5brW+O27 06/n2w/xeNOpCtVgFu7kyqa/yHAtVrPNVe0AG8RNmyWtGm6l3Dp6XI+4qJN67ysVFmzk u/6AocBVjG4DzUrdH+g3JrBhEzUTRLUdc2m7lje9Jga1X9XZiJJh2UrwYI1i4na1xJVM D6akSy+8vUKQyaNRchRLbYCxGU1tKrg2WLP0l78iyxhvJ1T8mpqRLHdq6RWEuktnU0uX GtX6WEmWF0pghstHhYhNRmsiTABZR1eoz0SJVbiU/eq5+GeyQ6G+VPg2nAr45egGXgOm xbUQ== MIME-Version: 1.0 X-Received: by 10.69.29.107 with SMTP id jv11mr12723292pbd.147.1386464741382; Sat, 07 Dec 2013 17:05:41 -0800 (PST) In-Reply-To: <27c0b454-62e9-410f-b05c-7c5fe306f8aa@googlegroups.com> References: <27c0b454-62e9-410f-b05c-7c5fe306f8aa@googlegroups.com> Date: Sun, 8 Dec 2013 12:05:41 +1100 Subject: Re: Is It Bug? From: Chris Angelico Cc: "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: 1386464744 news.xs4all.nl 2869 [2001:888:2000:d::a6]:50970 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61264 On Sun, Dec 8, 2013 at 11:59 AM, Mahan Marwat wrote: > Why this is not working. > >>>> 'Hello, \\\\World'.replace('\\', '\\') > > To me, Python will interpret '\\\\' to '\\'. And the replace method will replace '\\' with '\'. So, the result will be 'Hello, \World'. But it's give me 'Hello, \\\\World'. > > The result I want form the code is 'Hello, \World'. You're replacing with the same as the source string. That's not going to change anything. The first thing to get your head around is Python string literals. You'll find them well described in the online tutorial, or poke around in the interactive interpreter. Once you master that, you should be able to understand what you're trying to do here. ChrisA