[Tutor] Asterisk

Bob Gailer ramrom@earthling.net
Wed Dec 4 17:39:07 2002


--=====================_28702892==.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed

At 06:48 PM 12/4/2002 -0330, Adam Vardy wrote:
 > Why does this happen? It is a strange expression.
 > >>> '%*.*f' % (6,3,1.41421356)
 > ' 1.414'

That's what I'd expect. Did you rtfm?

"""A conversion specifier contains two or more characters and has the 
following components, which must occur in this order:
1 The "%" character, which marks the start of the specifier.
2 Mapping key value (optional), consisting of an identifier in parentheses 
(for example, (somename)).
3 Conversion flags (optional), which affect the result of some conversion 
types.
4 Minimum field width (optional). If specified as an "*" (asterisk), the 
actual width is read from the next element of the tuple in values, and the 
object to convert comes after the minimum field width and optional precision.
5 Precision (optional), given as a "." (dot) followed by the precision. If 
specified as "*" (an asterisk), the actual width is read from the next 
element of the tuple in values, and the value to convert comes after the 
precision.
6 Length modifier (optional).
7 Conversion type."""

In your example there is (1) % (4) * (5) .* (7) f. What more can I say?

Bob Gailer
mailto:ramrom@earthling.net
303 442 2625

--=====================_28702892==.ALT
Content-Type: text/html; charset="us-ascii"

<html>
<body>
At 06:48 PM 12/4/2002 -0330, Adam Vardy wrote:<br>
&gt; Why does this happen? It is a strange expression.<br>
&gt; &gt;&gt;&gt; '%*.*f' % (6,3,1.41421356)<br>
&gt; ' 1.414'<br><br>
That's what I'd expect. Did you rtfm?<br><br>
&quot;&quot;&quot;A conversion specifier contains two or more characters
and has the following components, which must occur in this order: <br>
1 The &quot;<tt>%</tt>&quot; character, which marks the start of the
specifier. <br>
2 Mapping key value (optional), consisting of an identifier in
parentheses (for example, (somename)). <br>
3 Conversion flags (optional), which affect the result of some conversion
types. <br>
4 Minimum field width (optional). If specified as an
&quot;<tt>*</tt>&quot; (asterisk), the actual width is read from the next
element of the tuple in values, and the object to convert comes after the
minimum field width and optional precision. <br>
5 Precision (optional), given as a &quot;<tt>.</tt>&quot; (dot) followed
by the precision. If specified as &quot;<tt>*</tt>&quot; (an asterisk),
the actual width is read from the next element of the tuple in values,
and the value to convert comes after the precision. <br>
6 Length modifier (optional). <br>
7 Conversion type.&quot;&quot;&quot;<br><br>
In your example there is (1) % (4) * (5) .* (7) f. What more can I
say?<br>
<x-sigsep><p></x-sigsep>
Bob Gailer<br>
<a href="mailto:ramrom@earthling.net" eudora="autourl">mailto:ramrom@earthling.net</a><br>
303 442 2625<br>
</body>
</html>

--=====================_28702892==.ALT--