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


Groups > comp.lang.python > #61263

Re: Is It Bug?

References <5865401e-aef8-4dd2-927c-52d2b7ca3ed8@googlegroups.com>
From Iuri <iurisilvio@gmail.com>
Date 2013-12-07 23:04 -0200
Subject Re: Is It Bug?
Newsgroups comp.lang.python
Message-ID <mailman.3712.1386464680.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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
>

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


Thread

Is It Bug? Mahan Marwat <mahanmarwat@gmail.com> - 2013-12-07 16:58 -0800
  Re: Is It Bug? Iuri <iurisilvio@gmail.com> - 2013-12-07 23:04 -0200
  Re: Is It Bug? rusi <rustompmody@gmail.com> - 2013-12-07 21:48 -0800
  Re: Is It Bug? Joshua Gardner <mellowcellofellow@gmail.com> - 2013-12-07 23:39 -0700

csiph-web