I do this a lot in Perl:
printf \"%8s %8s %8s\\n\", qw(date price ret);
However, the best I can come up with in Python is
p
QW()
is often used to print column headings using join()
in Perl. Column heads in the real-world are sometimes long -- making join("\t", qw())
very useful because it's easier to read and helps to eliminate typos (e.g. "x","y"
or "x\ty"
). Below is a related approach in real-world Python:
print("\t".join('''PubChemId Column ESImode Library.mzmed
Library.rtmed Metabolite newID Feature.mzmed Feature.rtmed
Count ppmDiff rtDiff'''.split()))
The triple quote string is a weird thing because it doubles as a comment. In this context, however, it is a string and it frees us from having to worry about line breaks (as qw()
would).
Thanks to the previous replies for reveling this approach.