Is It Bug?

rusi rustompmody at gmail.com
Sun Dec 8 06:48:36 CET 2013


On Sunday, December 8, 2013 6:28:24 AM UTC+5:30, 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'.

I am mystified by this question.
Yes '\\' may be one slash or two or something else more exotic.
But whatever it is (and its not a syntax error like with '\') it is something.
So how can ....replace(something,something)....  be anything other
than a no-op?




More information about the Python-list mailing list