From fd412e16c5321de68b92dccd82d17ecd9cf398c4 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Thu, 12 Mar 2009 19:36:28 +0000 Subject: [PATCH] Add research on what C Sharp does. --- pep-0378.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pep-0378.txt b/pep-0378.txt index 5360b0827..4dea841f9 100644 --- a/pep-0378.txt +++ b/pep-0378.txt @@ -60,10 +60,12 @@ specifiers like:: "_($* #,##0_)". -COBOL uses picture clauses like:: +`COBOL`_ uses picture clauses like:: PIC $***,**9.99CR +.. _`COBOL`: http://en.wikipedia.org/wiki/Cobol + `Common Lisp`_ uses a COLON before the ``~D`` decimal type specifier to emit a COMMA as a thousands separator. The general form of ``~D`` is ``~mincol,padchar,commachar,commaintervalD``. The *padchar* defaults @@ -76,6 +78,17 @@ defaults to three. .. _`Common Lisp`: http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node200.html +`C-Sharp`_ provides both styles (picture formatting and type specifiers). +The type specifier approach is locale aware. The picture formatting only +offers a COMMA as a thousands separator:: + + String.Format("{0:c}", 12400) ==> "$12,400" + String.Format("{0:n}", 12400) ==> "12,400" + String.Format("{0:0,0}", 12400) ==> "12,400" + +.. _`C-Sharp`: http://blog.stevex.net/index.php/string-formatting-in-csharp/ + + Proposal I (from Nick Coghlan) ==============================