A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-November/030307.html below:

[Python-Dev] Yet another string formatting proposal

[Python-Dev] Yet another string formatting proposal [Python-Dev] Yet another string formatting proposalOren Tirosh oren-py-d@hishome.net
Thu, 21 Nov 2002 21:53:23 +0200
On Thu, Nov 21, 2002 at 08:24:54PM +0100, Fredrik Lundh wrote:
> oren won't give up:
> 
> 
> >     "\(a) + \(b) = \(a+b)\n"
> > 
> > The expressions embedded in the string are parsed at compile time and
> > any syntax errors in them are detected during compilation.
> 
> note that "\(" is commonly used to escape parentheses in regular
> expression strings.

Yes, it might break some existing code that doesn't use proper \\ escaping
or raw strings for regular expression. Note that such code is already 
broken in the sense that it uses an undefined escape.

If this turns out to be a real problem a possible alternative is to use
curly braces. There is a precedent for this in u"\N{UNICODE CHAR NAMES}"
Braces are also more visually distinctive and less confusing when the 
expression itself contains parentheses:

print "X=\{x}, y=\{calc_y(x)}"

        Oren




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4