[Tutor] How does formatted printing work?

Steven D'Aprano steve at pearwood.info
Sat Jun 8 20:03:54 CEST 2013


On 09/06/13 01:58, Michael Sparks wrote:
> You can explain it yourself or just drop me a link (or both).
> Right now I'm learning Python 2.x but I plan on learning Python 3.x as well.


Formatted printing? First you format something, then you print it.

Other than that, you will need to explain your question in more detail. I can't read your mind, so I don't know if you're having trouble understanding "formatting" (which formatting? there are at least four things which might be described as "formatting") or "printing" (which printing? there are at least three things which might be described as "printing").

So please don't assume that just because a question is clear and obvious in your mind, it is necessarily clear and obvious to everyone else.


And for the record:

1) format() built-in function;
2) str.format() method;
3) % string interpolation;
4) string templates;

and

1) printing to an actual printer;
2) print statement;
3) the pprint ("pretty printing") module.



-- 
Steven


More information about the Tutor mailing list