Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'skip:\\ 20': 0.07; 'cc:addr:python-list': 0.11; 'python': 0.11; "'\\\\'": 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'working.': 0.19; '>>>': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; '>>>': 0.24; 'interpret': 0.24; 'replace': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'url:python': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'method': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'so,': 0.37; 'pm,': 0.38; 'url:mail': 0.40; 'to:addr:gmail.com': 0.65; '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:from:date:message-id:subject:to :cc:content-type; bh=851AfkjLVt9+7x2hT31C1yo8g5802rmzWZxaBddu0iI=; b=IdleFdeCKcUhKgr3xy4JG9Yli4bodFoQzr3fCg96D8qfmMiZiiLN5MJuQPjRFqwfRN WcGHq+A1Z+Gwu+YKfNR3Wj4X+KevJotDd1+ffkveAw1OanzJJOKHdtlJUtfrONFchSqo T2sm6sJz9G/NZ3pImRNF1m0bGSWaas02/i1qXgirVRq1sGURdPqErltwjh92PChSIuy7 GUk6MamcRPZxj6tv2DpfBV8c/LlMdzwJPhtLhSGNaZT1hutk4JMDWHnMdQoBKDrmIGxS OAqAqFDNwogpKkZVmqEd8Aiwe8fQTu6N0qPMwZdGEUsiS6LnnTQpeGS5oYFFjG+xRKsd KiyA== X-Received: by 10.194.9.100 with SMTP id y4mr9479165wja.22.1386464673786; Sat, 07 Dec 2013 17:04:33 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <5865401e-aef8-4dd2-927c-52d2b7ca3ed8@googlegroups.com> References: <5865401e-aef8-4dd2-927c-52d2b7ca3ed8@googlegroups.com> From: Iuri Date: Sat, 7 Dec 2013 23:04:13 -0200 Subject: Re: Is It Bug? To: Mahan Marwat Content-Type: multipart/alternative; boundary=047d7b5d58a25ff43104ecfb7690 Cc: python-list 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: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386464680 news.xs4all.nl 2970 [2001:888:2000:d::a6]:49731 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61263 --047d7b5d58a25ff43104ecfb7690 Content-Type: text/plain; charset=ISO-8859-1 This way, it will replace '\' with '\', so nothing change. >>> 'Hello, \\\\World'.replace('\\\\', '\\') 'Hello, \\World' >>> print 'Hello, \\\\World'.replace('\\\\', '\\') Hello, \World On Sat, Dec 7, 2013 at 10:58 PM, 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'. > -- > https://mail.python.org/mailman/listinfo/python-list > --047d7b5d58a25ff43104ecfb7690 Content-Type: text/html; charset=ISO-8859-1
This way, it will replace '\' with '\', so nothing change.

>>> 'Hello, \\\\World'.replace('\\\\', '\\')
'Hello, \\World'
>>> print 'Hello, \\\\World'.replace('\\\\', '\\')
Hello, \World


On Sat, Dec 7, 2013 at 10:58 PM, Mahan Marwat <mahanmarwat@gmail.com> 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'.
--
https://mail.python.org/mailman/listinfo/python-list

--047d7b5d58a25ff43104ecfb7690--