print syntax

Benjamin Kaplan benjamin.kaplan at case.edu
Thu Sep 3 12:50:36 EDT 2009


On Thu, Sep 3, 2009 at 12:22 PM, <doug at safeport.com> wrote:
> I am new to python, working by way through 'Core Python Programming'. I can
> find no description of using print with the built-in type for formatting. I
> think I have got some [most?] of it from Chun, google, and python.org. My
> comment is - it should not be that hard to find. I would suggest a link from
> the print syntax section.
>
> What is seems to be is:
>
>  print "format-spec" % (variable-list)
>
> I assume the '%' is required token.
>

The % has absolutely nothing to do with the print statement. The (old)
formatting syntax is based on the C printf syntax but it's actually
the modulo operator on a string, not a piece of the print statement.
The documentation for it is in the documentation for strings.

>
>
> _____
> Douglas Denault
> http://www.safeport.com
> doug at safeport.com
> Voice: 301-217-9220
>  Fax: 301-217-9277
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list