<meta http-equiv="content-type" content="text/html; charset=utf-8"><div>hello, </div><div><br></div><div>I think I may have found a bug in the documentation under <span class="Apple-style-span" style="color: rgb(32, 67, 92); font-family: 'Trebuchet MS', sans-serif; "><a href="http://docs.python.org/tutorial/inputoutput.html#fancier-output-formatting">7.1. Fancier Output Formatting</a></span></div>
<div><br></div><div>as I am a beginner, I really do not have many ideas on how to fix it. </div><div><br></div><div>also as this is a simpleton error, there may already be discussion on a fix.</div><div><br></div><div><font class="Apple-style-span" color="#3333FF" size="4"><b>1)</b></font> You will see the following code.</div>
<div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 16px; "><pre style="overflow-x: auto; overflow-y: hidden; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(238, 255, 204); color: rgb(51, 51, 51); line-height: 15px; border-top-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-bottom-style: solid; border-top-color: rgb(170, 204, 153); border-bottom-color: rgb(170, 204, 153); border-left-style: none; border-left-width: initial; border-left-color: initial; border-right-style: none; border-right-width: initial; border-right-color: initial; ">
<span class="gp" style="color: rgb(198, 93, 9); font-weight: bold; ">>>> </span><span class="kn" style="color: rgb(0, 112, 32); font-weight: bold; ">import</span> <span class="nn" style="color: rgb(14, 132, 181); font-weight: bold; ">math</span>
<span class="gp" style="color: rgb(198, 93, 9); font-weight: bold; ">>>> </span><span class="k" style="color: rgb(0, 112, 32); font-weight: bold; ">print</span> <span class="s" style="color: rgb(64, 112, 160); ">'The value of PI is approximately {}.'</span><span class="o" style="color: rgb(102, 102, 102); ">.</span><span class="n">format</span><span class="p">(</span><span class="n">math</span><span class="o" style="color: rgb(102, 102, 102); ">.</span><span class="n">pi</span><span class="p">)</span>
<span class="go" style="color: rgb(48, 48, 48); ">The value of PI is approximately 3.14159265359.</span>
<span class="gp" style="color: rgb(198, 93, 9); font-weight: bold; ">>>> </span><span class="k" style="color: rgb(0, 112, 32); font-weight: bold; ">print</span> <span class="s" style="color: rgb(64, 112, 160); ">'The value of PI is approximately {!r}.'</span><span class="o" style="color: rgb(102, 102, 102); ">.</span><span class="n">format</span><span class="p">(</span><span class="n">math</span><span class="o" style="color: rgb(102, 102, 102); ">.</span><span class="n">pi</span><span class="p">)</span>
<span class="go" style="color: rgb(48, 48, 48); ">The value of PI is approximately 3.141592653589793.</span></pre></span></div><div><font class="Apple-style-span" color="#000099" size="4"><b>2) </b></font></div><div>When entered into Python, it complains</div>
<div><br></div><div><div>Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) </div><div>[GCC 4.4.5] on linux2</div><div>Type "help", "copyright", "credits" or "license" for more information.</div>
<div>>>> import math</div><div>>>> print 'The value of PI is approximately {}.'.format(math.pi)</div><div>Traceback (most recent call last):</div><div> File "<stdin>", line 1, in <module></div>
<div>ValueError: zero length field name in format</div><div>>>> print 'The value of PI is approximately {!r}.'.format(math.pi)</div><div>Traceback (most recent call last):</div><div> File "<stdin>", line 1, in <module></div>
<div>ValueError: zero length field name in format</div><div>>>> </div></div><div><br></div><div><br></div><div><br></div>