Brian wrote:
> Thanks guys, that really helped. Am I to assume that the * references
> the args in the parens?
Better than assuming, you can read all about it:
http://docs.python.org/lib/typesseq-strings.html
-Peter
--
http://mail.python.org/mailman/listinfo/python-list
Thanks guys, that really helped. Am I to assume that the * references
the args in the parens?
Thanks,
Brian
--
http://mail.python.org/mailman/listinfo/python-list
Brian wrote:
> I am a bit stuck with a float formatting issue. What I want to do is
> print a float to the screen with each line showing one more decimal
> place. Here is a code snip that may explain it better:
>
> #!/usr/bin/env python
>
> num1 = 32
> num2 = 42.98765
>
> for i in range(2,7):
> for i in range(2,7):
> print "|" + "%10.if" % num2 + "|" #where i would be the iteration
> and the num of decimal places
>>> for places in range(2,7):
... print "|%10.*f|" % (places, num2)
...
| 42.99|
|42.988|
| 42.9877|
On 25 Jan 2006 11:32:27 -0800 in comp.lang.python, "Brian"
<[EMAIL PROTECTED]> wrote:
>Hello all,
>
>I am a bit stuck with a float formatting issue. What I want to do is
>print a float to the screen with each line showing one more decimal
>place. Here is a code snip that may explain it better:
>
> However, if I do that I get errors saying that all args were not
> converted during string formatting. An escaped 'i' does not work
> either.
You need to format the string twice - first, to generate the float
formatting string, and then to format the string.
Like this:
num = 7.1234567890123