Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Streamline this format code
#1
Assuming each variable is to be formatted the same way, is there a way to avoid coding '${:,.0f}' in front of every variable that is to be printed on a line?

print(hdr62.format(
                           '${:,.0f}'.format(ETE).rjust(12, ' '),
                           '${:,.0f}'.format(ETFI).rjust(12, ' '),
                           '${:,.0f}'.format(ETC).rjust(12, ' '),
                           '${:,.0f}'.format(ETTA).rjust(12, ' '),
                           '${:,.0f}'.format(ETFE).rjust(12, ' '),
                           '${:,.0f}'.format(ETFFI).rjust(12, ' '),
                           '${:,.0f}'.format(ETFC).rjust(12, ' ')))
by the way, hdr62 is just a spacing format, like '{:>13}'

thanks
Reply


Messages In This Thread
Streamline this format code - by birdieman - Jan-18-2017, 05:54 PM
RE: Streamline this format code - by micseydel - Jan-18-2017, 06:53 PM
RE: Streamline this format code - by wavic - Jan-18-2017, 06:58 PM
RE: Streamline this format code - by birdieman - Jan-18-2017, 07:40 PM
RE: Streamline this format code - by wavic - Jan-18-2017, 07:46 PM
RE: Streamline this format code - by birdieman - Jan-18-2017, 07:48 PM
RE: Streamline this format code - by wavic - Jan-18-2017, 07:51 PM
RE: Streamline this format code - by micseydel - Jan-18-2017, 07:49 PM
RE: Streamline this format code - by birdieman - Jan-18-2017, 08:00 PM
RE: Streamline this format code - by birdieman - Jan-19-2017, 12:53 AM
RE: Streamline this format code - by birdieman - Jan-19-2017, 02:28 PM
RE: Streamline this format code - by micseydel - Jan-19-2017, 06:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  An unexplainable error in .format statement - but only in a larger piece of code? ToniE 4 725 Sep-05-2023, 12:50 PM
Last Post: ToniE
  Please suggest python code to format DNA sequence FASTA file rajamdade 4 3,196 Oct-24-2019, 04:36 AM
Last Post: rajamdade
  code help to convert log file to csv format bmunagala 3 12,165 Jan-21-2019, 06:08 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020