re.sub
DiPierro, Massimo
MDiPierro at cti.depaul.edu
Tue Oct 16 14:16:07 EDT 2007
That is not the problem. The problem is that
re.sub('a','\\n','bab')
cannot be the same as
re.sub('a','\n','bab')
This is evaluating the string to be substituted before the substitution.
Massimo
________________________________________
From: python-list-bounces+mdipierro=cti.depaul.edu at python.org [python-list-bounces+mdipierro=cti.depaul.edu at python.org] On Behalf Of Chris Mellon [arkanes at gmail.com]
Sent: Tuesday, October 16, 2007 1:12 PM
To: python-list at python.org
Subject: Re: re.sub
On 10/16/07, Massimo Di Pierro <mdipierro at cti.depaul.edu> wrote:
> Even stranger
>
> >>> re.sub('a', '\\n','bab')
> 'b\nb'
> >>> print re.sub('a', '\\n','bab')
> b
> b
>
You called print, so instead of getting an escaped string literal, the
string is being printed to your terminal, which is printing the
newline.
--
http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list