Re: [Tutor] Making table

2007-03-22 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote in message >> One final tip is to put the format string in a variable then use >> that >> in printing/writing the output ... >> This has the advantage that you can build the format string >> dynamically by examining the data first - eg the maximum >> leng

Re: [Tutor] Making table

2007-03-21 Thread Kent Johnson
Alan Gauld wrote: > others have discussed format strings. > One final tip is to put the format string in a variable then use that > in printing/writing the output > > eg: > > fmt = '%10.3f\t%10.3f\t%10.3f' > print fmt % v1,v2,v3 > > This has the advantage that you can build the format string > d

Re: [Tutor] Making table

2007-03-21 Thread Alan Gauld
"Per Jr. Greisen" <[EMAIL PROTECTED]> wrote > I need to generate a table with different x,y,z values and write > them to a > file: > 10.171 -15.243 -2.558 > 9.837 -14.511 -1.923 > -23.451 -13.870 51.507 > others have discussed format strings. One final tip is to put the format string in a va

Re: [Tutor] Making table

2007-03-21 Thread Carroll, Barry
> -Original Message- > Date: Tue, 20 Mar 2007 22:53:15 +0100 > From: J?nos Juh?sz <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Making table > To: tutor@python.org > Message-ID: >[EMAIL PROTECTED]> > Content-Type: text/plain; charset="iso-8

Re: [Tutor] Making table

2007-03-20 Thread János Juhász
Dear Barry, >>Using a formatting string of "%10.4f", these would be rendered as: >> >> ' 253.' >> ' 77.6000 >> '9.0300' >> '0.0210' >> >>This formatting gives the impression that all values but the last are >>more precise than

Re: [Tutor] Making table

2007-03-20 Thread Kent Johnson
Carroll, Barry wrote: > This formatting gives the impression that all values but the last are > more precise than they truly are. A scientist or statistician would > prefer to see something like this: > > '254.' > ' 77.6 ' > ' 9.03 ' > ' 0.0210' > > Does numpy or

Re: [Tutor] Making table

2007-03-19 Thread Carroll, Barry
> -Original Message- > From: Kent Johnson [mailto:[EMAIL PROTECTED] > Sent: Monday, March 19, 2007 12:59 PM > To: Carroll, Barry > Cc: tutor@python.org > Subject: Re: [Tutor] Making table > > Carroll, Barry wrote: > >> -Original Message- > >

Re: [Tutor] Making table

2007-03-19 Thread Kent Johnson
Carroll, Barry wrote: >> -Original Message- >> Date: Mon, 19 Mar 2007 11:53:06 -0400 >> From: Kent Johnson <[EMAIL PROTECTED]> >> Most string formatting conversions allow you to specify a width >> directly. For example, >> In [61]: value = 3.45678 >> In [63]: "%10.3f" % value >> Out[63]: '

Re: [Tutor] Making table

2007-03-19 Thread Carroll, Barry
> -Original Message- > Date: Mon, 19 Mar 2007 11:53:06 -0400 > From: Kent Johnson <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Making table > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Re: [Tutor] Making table

2007-03-19 Thread Kent Johnson
Dave Kuhlman wrote: > Try ljust and rjust. They are string functions/methods and are > described here: http://docs.python.org/lib/string-methods.html > > Something like the following might work for you: > > In [1]: value = 3.45678 > In [2]: ("%0.3f" % value).rjust(10) > Out[2]: '

Re: [Tutor] Making table

2007-03-19 Thread Dave Kuhlman
On Mon, Mar 19, 2007 at 01:11:27PM +0100, Per Jr. Greisen wrote: > Hi, > I need to generate a table with different x,y,z values and write them to a > file: > 10.171 -15.243 -2.558 > 9.837 -14.511 -1.923 > -23.451 -13.870 51.507 > > I would like to write to the files as columns > 10.171 -15.24

[Tutor] Making table

2007-03-19 Thread Per Jr. Greisen
Hi, I need to generate a table with different x,y,z values and write them to a file: 10.171 -15.243 -2.558 9.837 -14.511 -1.923 -23.451 -13.870 51.507 I would like to write to the files as columns 10.171 -15.243 -2.558 9.837 -14.511 -1.923 -23.451 -13.870 51.507 0.233 0.453