Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Query about doing fortran-esque repeat formatting
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Rob Briggs  
View profile   Translate to Translated (View Original)
 More options 8 Nov, 14:56
Newsgroups: comp.lang.python
From: Rob Briggs <rdbri...@mun.ca>
Date: Sun, 08 Nov 2009 11:26:18 -0330
Local: Sun 8 Nov 2009 14:56
Subject: Query about doing fortran-esque repeat formatting
Hello,

Is there a way to do a repeat formatting command like in Fortran? Rather
that doing this:

print "%s %-5.3f %-5.3f %-5.3f %-5.3f %-5.3f %-5.3f %-5.3f" %
(parmName[i], tmp[i][1], tmp[i][2], tmp[i][4],  tmp[i][6],  tmp[i][7],
tmp[i][8],  tmp[i][9])

Something like this:

print "%s 7%-5.3f % (parmName[i], tmp[i][1], tmp[i][2], tmp[i][4],
tmp[i][6],  tmp[i][7], tmp[i][8],  tmp[i][9])

regards,

Rob


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mensanator  
View profile   Translate to Translated (View Original)
 More options 8 Nov, 16:08
Newsgroups: comp.lang.python
From: Mensanator <mensana...@aol.com>
Date: Sun, 8 Nov 2009 08:08:55 -0800 (PST)
Local: Sun 8 Nov 2009 16:08
Subject: Re: Query about doing fortran-esque repeat formatting
On Nov 8, 8:56 am, Rob Briggs <rdbri...@mun.ca> wrote:

'%s  %-5.4f %-5.4f %-5.4f %-5.4f %-5.4f %-5.4f %-5.4f'
>>> print s % ('s',1,2,3,4,5,6,7)

s  1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Novocastrian_Nomad  
View profile   Translate to Translated (View Original)
 More options 9 Nov, 00:56
Newsgroups: comp.lang.python
From: Novocastrian_Nomad <gregory.j.ba...@gmail.com>
Date: Sun, 8 Nov 2009 16:56:40 -0800 (PST)
Local: Mon 9 Nov 2009 00:56
Subject: Re: Query about doing fortran-esque repeat formatting
How about:

print ('%s ' + '%-5.4f ' * 7) % ('text',1,2,3,4,5,6,7)


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Glenn Hutchings  
View profile   Translate to Translated (View Original)
 More options 9 Nov, 12:05
Newsgroups: comp.lang.python
From: Glenn Hutchings <zond...@googlemail.com>
Date: Mon, 9 Nov 2009 12:05:54 +0000 (UTC)
Local: Mon 9 Nov 2009 12:05
Subject: Re: Query about doing fortran-esque repeat formatting
Rob Briggs <rdbriggs <at> mun.ca> writes:

> Is there a way to do a repeat formatting command like in Fortran? Rather
> that doing this:

> print "%s %-5.3f %-5.3f %-5.3f %-5.3f %-5.3f %-5.3f %-5.3f" %
> (parmName[i], tmp[i][1], tmp[i][2], tmp[i][4],  tmp[i][6],  tmp[i][7],
> tmp[i][8],  tmp[i][9])

There certainly is.  You can use python's string concatenation
and repeat operators:

print "%s" + " %-5.3f" * 7 % <stuff>

Glenn


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rob Briggs  
View profile   Translate to Translated (View Original)
 More options 9 Nov, 14:53
Newsgroups: comp.lang.python
From: Rob Briggs <rdbri...@mun.ca>
Date: Mon, 09 Nov 2009 11:23:23 -0330
Local: Mon 9 Nov 2009 14:53
Subject: Re: Query about doing fortran-esque repeat formatting
Thanks to the chaps who answered,  

I knew there would be an efficient answer to this.

regards,

Rob


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google