[Python-checkins] r54264 - sandbox/trunk/pep3101/doctests/basic_examples.txt

patrick.maupin python-checkins at python.org
Sat Mar 10 19:51:11 CET 2007


Author: patrick.maupin
Date: Sat Mar 10 19:51:06 2007
New Revision: 54264

Modified:
   sandbox/trunk/pep3101/doctests/basic_examples.txt
Log:
Added comment example

Modified: sandbox/trunk/pep3101/doctests/basic_examples.txt
==============================================================================
--- sandbox/trunk/pep3101/doctests/basic_examples.txt	(original)
+++ sandbox/trunk/pep3101/doctests/basic_examples.txt	Sat Mar 10 19:51:06 2007
@@ -89,6 +89,20 @@
 >>> print f("{z.c[5].b[1].a[3]}")
 42
 
+
+        As any Python programmer knows, access to deeply embedded
+        attributes can create lengthy source lines.  The best way
+        to keep format string source lines to a reasonable length
+        (while still allowing arbitrary-length output lines) is
+        to embed non-printing comments inside the format string.
+
+>>> print f("""The product of {z.c[5].b[1].a[7]} and {z.c[5].b[1].a[4]} {#
+... This is a comment.  It starts with {# and ends with the next }.
+... As you can see, I have nested { and }, which only works if each
+... nested { has a corresponding } somewhere after it in the comment.
+... }is {z.c[5].b[1].a[3]}.""")
+The product of 6 and 7 is 42.
+
         Attributes and indices can even be retrieved from other variables.
         NB: Unless somebody has a really good use case, this capability
         is probably going away.  It was added to try to satisfy Ian's


More information about the Python-checkins mailing list