[Tutor] Style help: long strings with formatting

W W srilyk at gmail.com
Tue Jul 29 19:02:16 CEST 2008


I've been dinking around, making a program that will find out how different
factors affect what you *really* save on gas, and at the end I have it
output some information, but I'm not sure what the right style for
formatting is.

output = "At an average weekly savings of $%.02f, your monthly savings  will
be $%.02f. \n Your annual savings will be $%.02f." % (diff, monthly_savings,
print output.

As you can see, it's very much longer than the 72 characters suggested in
the PEP 8 found here: http://www.python.org/dev/peps/pep-0008/

I know it would be fairly trivial to split it up into several strings, and
concatenating or printing each one. I've tried using the \ line continuation
to break up the string, however that leaves the indentation inside the
string. Breaking the string up with commas or even concatenation gives
issues with the % operation.

So my question is, what is the proper stylistic way to render my text? Also,
I don't know if I just looked over it, or if it honestly didn't exist
anywhere I looked for it, but I couldn't find any naming conventions for
regular ol' variables. I found plenty for functions, classes, etc., so I'm
not sure if my underscores are proper for my variables or if I should fix


To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn't. - Primo Levi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080729/d2af94fc/attachment.htm>

More information about the Tutor mailing list