[Tutor] positional output

Dave Angel d at davea.name
Thu Nov 10 22:24:50 CET 2011


On 11/10/2011 03:54 PM, Cranky Frankie wrote:
> What is the easiest way in Python 3.x to write output positionally?
> For example I have one literal I want in column 1, the next one in
> column 40, the third one in column 50. I've tried usings tabs and I'm
> not getting what I want. Is it something to do with C style printf
> formatting? An example would be greatly appreciated.
>
Narrow down your environment a bit.  Where is this output going?  To a 
file, to a printer, to the console?  If the latter, in what environment?

The only portable way to position yourself would be to pad with spaces.  
If you want to output a fixed width string, perhaps you'd want to use 
the format method of str.
-- 

DaveA



More information about the Tutor mailing list