[issue3516] string formatting quirk using %.%

2008-08-07 Thread nadav
and cannot be deduced from the documentation. -- components: Interpreter Core messages: 70822 nosy: blop severity: normal status: open title: string formatting quirk using %.% type: behavior ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org

[issue3516] string formatting quirk using %.%

2008-08-07 Thread Guido van Rossum
Guido van Rossum [EMAIL PROTECTED] added the comment: It's straightforward if you consider the implementation of the requirement that %% renders a single percent sign: the second % is parsed just like any other formatting code (i, d, f, etc.) and the stuff between the first % and the formatting

[issue3516] string formatting quirk using %.%

2008-08-07 Thread nadav
nadav [EMAIL PROTECTED] added the comment: The main problem with this is that the following code does not make any sense: %(a)% % dict(a=3) It has no semantic meaning (take the dictionary paramater a, and do nothing with it). It must be a user bug (except in very wierd cases). I agree that

[issue3516] string formatting quirk using %.%

2008-08-07 Thread Georg Brandl
Georg Brandl [EMAIL PROTECTED] added the comment: I'd rather see it this way: It is a programming error if a format string contains a reference to a nonexisting dictionary key, no matter what formatting specifier is used. The implementation is quite consistent here. -- nosy:

[issue2773] Wrong description of 'g' conversion type of string formatting operator %

2008-05-06 Thread Artur Zaprzała
New submission from Artur Zaprzała [EMAIL PROTECTED]: Description of 'g' and 'G' conversion types of string formatting operator at http://www.python.org/doc/2.5.2/lib/typesseq-strings.html is: Floating point format. Uses exponential format if exponent is greater than -4 or less than precision

[issue2773] Wrong description of 'g' conversion type of string formatting operator %

2008-05-06 Thread Georg Brandl
Georg Brandl [EMAIL PROTECTED] added the comment: Thanks, fixed in r62774. -- resolution: - fixed status: open - closed __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2773 __

[issue2773] Wrong description of 'g' conversion type of string formatting operator %

2008-05-06 Thread Artur Zaprzała
Artur Zaprzała [EMAIL PROTECTED] added the comment: The fix is wrong. not less == greater than or equal to __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2773 __ ___

[issue2773] Wrong description of 'g' conversion type of string formatting operator %

2008-05-06 Thread Georg Brandl
Georg Brandl [EMAIL PROTECTED] added the comment: Argh, fixed in r62775. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2773 __ ___ Python-bugs-list mailing list Unsubscribe:

[issue2416] % string formatting does not support %b

2008-04-18 Thread Eric Smith
Eric Smith [EMAIL PROTECTED] added the comment: On the python-3000 list we decided not to add new features to % formatting, since it will be deprecated in favor of str.format. -- resolution: - wont fix status: open - closed __ Tracker [EMAIL PROTECTED]

[issue2416] % string formatting does not support %b

2008-04-18 Thread Eric Smith
Eric Smith [EMAIL PROTECTED] added the comment: I should have noted that the PEP was modified to remove %b and %#b formatting. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2416 __

Re: question about string formatting

2008-04-09 Thread G
import locale locale.setlocale(locale.LC_ALL, '') 'en_US.UTF-8' locale.format('%.2f', 1021212.12, True) '1,021,212.12' On Wed, Apr 9, 2008 at 1:04 PM, Kelie [EMAIL PROTECTED] wrote: Hello, Is there something in Python built-in function or library that will convert a number 1205466.654 to

question about string formatting

2008-04-09 Thread Kelie
Hello, Is there something in Python built-in function or library that will convert a number 1205466.654 to $1,205,466.65? To add the $ sign and set the decimal place is not a problem, but I don't know how to add the thousands delimiter. Thanks, -- Kelie UliPad http://code.google.com/p/ulipad/

Re: question about string formatting

2008-04-09 Thread Jerry Hill
On Wed, Apr 9, 2008 at 1:04 PM, Kelie [EMAIL PROTECTED] wrote: Is there something in Python built-in function or library that will convert a number 1205466.654 to $1,205,466.65? To add the $ sign and set the decimal place is not a problem, but I don't know how to add the thousands delimiter.

Re: question about string formatting

2008-04-09 Thread Kelie
Thank you Jerry! -- Kelie UliPad http://code.google.com/p/ulipad/ is my Python editor. -- http://mail.python.org/mailman/listinfo/python-list

[issue2416] % string formatting does not support %b

2008-03-18 Thread Eric Smith
New submission from Eric Smith [EMAIL PROTECTED]: PEP 3127 Integer Literal Support and Syntax says that % string formatting should support %b. This needs to be added to both 2.6 and 3.0. It needs to support the forms %b and %#b. -- assignee: eric.smith components: Interpreter Core

Making string-formatting smarter by handling generators?

2008-02-27 Thread Tim Chase
Is there an easy way to make string-formatting smart enough to gracefully handle iterators/generators? E.g. transform = lambda s: s.upper() pair = ('hello', 'world') print %s, %s % pair # works print %s, %s % map(transform, pair) # fails with a TypeError: not enough arguments

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread grflanagan
On Feb 27, 5:23 pm, Tim Chase [EMAIL PROTECTED] wrote: Is there an easy way to make string-formatting smart enough to gracefully handle iterators/generators? E.g. transform = lambda s: s.upper() pair = ('hello', 'world') print %s, %s % pair # works print %s, %s % map(transform

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread D'Arcy J.M. Cain
On Wed, 27 Feb 2008 10:23:49 -0600 Tim Chase [EMAIL PROTECTED] wrote: I can force it by wrapping the results of my generator in a call to tuple() or list() I think you are wrong about list(). Since map() returns a list already it doesn't change anything. print %s, %s %

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Arnaud Delobelle
On Feb 27, 4:23 pm, Tim Chase [EMAIL PROTECTED] wrote: Is there an easy way to make string-formatting smart enough to gracefully handle iterators/generators?  E.g.    transform = lambda s: s.upper()    pair = ('hello', 'world')    print %s, %s % pair # works    print %s, %s % map(transform

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Boris Borcic
D'Arcy J.M. Cain wrote: I find I hit it mostly with calls to map() where I want to apply some transform (as above) to all the items in a list of parameters such as %s=%s%s=%s % map(urllib.quote, params) Isn't map() deprecated? The above can be done with; %s=%s%s=%s %

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Gabriel Genellina
En Wed, 27 Feb 2008 14:23:49 -0200, Tim Chase [EMAIL PROTECTED] escribi�: Is there an easy way to make string-formatting smart enough to gracefully handle iterators/generators? E.g. transform = lambda s: s.upper() pair = ('hello', 'world') print %s, %s % pair # works print

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Tim Chase
Is there an easy way to make string-formatting smart enough to gracefully handle iterators/generators? E.g. transform = lambda s: s.upper() pair = ('hello', 'world') print %s, %s % pair # works print %s, %s % map(transform, pair) # fails with a TypeError: not enough

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Arnaud Delobelle
On Feb 27, 5:25 pm, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote: On Wed, 27 Feb 2008 10:23:49 -0600 Tim Chase [EMAIL PROTECTED] wrote:    %s=%s%s=%s % map(urllib.quote, params) Isn't map() deprecated?  The above can be done with;     %s=%s%s=%s % tuple([urllib.quote(x) for x in params]) I

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Ben Finney
D'Arcy J.M. Cain [EMAIL PROTECTED] writes: The above can be done with; %s=%s%s=%s % tuple([urllib.quote(x) for x in params]) Or, better:: %s=%s%s=%s % tuple(urllib.quote(x) for x in params) passing a generator, instead of a list created from a generator, to the tuple constructor.

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Tim Chase
Note that your problem has nothing to do with map itself. String interpolation using % requires either many individual arguments, or a single *tuple* argument. A list is printed as itself. Just as an exercise to understand this better, I've been trying to figure out what allows for this

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread D'Arcy J.M. Cain
On Wed, 27 Feb 2008 13:06:27 -0800 (PST) Arnaud Delobelle [EMAIL PROTECTED] wrote: On Feb 27, 5:25 pm, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote: Isn't map() deprecated?  The above can be done with; I don't think that map() is deprecated. In python 3.0 it is still present, only it returns an

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Steven D'Aprano
On Wed, 27 Feb 2008 14:41:32 -0600, Tim Chase wrote: Is there an easy way to make string-formatting smart enough to gracefully handle iterators/generators? E.g. transform = lambda s: s.upper() pair = ('hello', 'world') print %s, %s % pair # works print %s, %s % map(transform

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: map() isn't deprecated, not even for Python 3 where it remains a built- in. However it will return an iterator instead of a list, making it (presumably) a more convenient way to spell itertools.imap(). That's the first I heard of that change. I guess

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Gabriel Genellina
En Wed, 27 Feb 2008 23:18:14 -0200, Steven D'Aprano [EMAIL PROTECTED] escribió: I think there is a good case for % taking an iterator. Here's an artificial example: def spam(): while True: yield spam spam = spam() %s eggs tomato and %s % spam %s %s bacon tomato %s and eggs % spam

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Gabriel Genellina
En Wed, 27 Feb 2008 20:40:04 -0200, Tim Chase [EMAIL PROTECTED] escribió: Note that your problem has nothing to do with map itself. String interpolation using % requires either many individual arguments, or a single *tuple* argument. A list is printed as itself. Just as an exercise to

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Steven D'Aprano
On Thu, 28 Feb 2008 00:03:02 -0200, Gabriel Genellina wrote: En Wed, 27 Feb 2008 23:18:14 -0200, Steven D'Aprano [EMAIL PROTECTED] escribió: I think there is a good case for % taking an iterator. Here's an artificial example: def spam(): while True: yield spam spam = spam() %s

Beginner String formatting question

2008-01-26 Thread JAMoore84
Hi all, I am trying to write a simple program that will accept an integral time input in the HHMMSS format and output a HH:MM:SS form. My code is as follows: import string def FormatTime(time): '''Converts an HHMMSS string to HH:MM:SS format.''' timeString =

Re: Beginner String formatting question

2008-01-26 Thread Mark Tolonen
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi all, I am trying to write a simple program that will accept an integral time input in the HHMMSS format and output a HH:MM:SS form. My code is as follows: import string def FormatTime(time):

Re: Beginner String formatting question

2008-01-26 Thread chaosgy
On 1月27日, 上午1时02分, [EMAIL PROTECTED] wrote: Hi all, I am trying to write a simple program that will accept an integral time input in the HHMMSS format and output a HH:MM:SS form. My code is as follows: import string def FormatTime(time): '''Converts an HHMMSS

Re: Beginner String formatting question

2008-01-26 Thread Gary Herron
[EMAIL PROTECTED] wrote: Hi all, I am trying to write a simple program that will accept an integral time input in the HHMMSS format and output a HH:MM:SS form. My code is as follows: import string def FormatTime(time): '''Converts an HHMMSS string to HH:MM:SS

Re: Beginner String formatting question

2008-01-26 Thread JAMoore84
I apologize for the lack of details in my last post. This time formatting program is a piece of a larger program I am trying to write to de-clutter GPS transmission. I have a GPS receiver that transmits its readings via bluetooth. I've been able to use pySerial and store X number of bytes, then

Re: Beginner String formatting question

2008-01-26 Thread John Machin
On Jan 27, 7:15 am, [EMAIL PROTECTED] wrote: I apologize for the lack of details in my last post. There is nothing to apologise for. Unlike some, you gave enough information, without prompting, to get answers to your questions. Don't go to the other extreme :-) This time formatting program

Re: Elementary string-formatting

2008-01-14 Thread Odysseus
In article [EMAIL PROTECTED], John Machin [EMAIL PROTECTED] wrote: snip div operator? The integer division operator is // Yes, sorry, that's what I meant. -- Odysseus -- http://mail.python.org/mailman/listinfo/python-list

Re: Elementary string-formatting

2008-01-13 Thread Odysseus
In article [EMAIL PROTECTED], John Machin [EMAIL PROTECTED] wrote: snip You obviously haven't tried float(n / m), or you wouldn't be asking. True, it was a very silly idea. Most legible and slowest first: 1. float(n) / float(m) 2. n / float(m) 3. 1.0 * n / m Recommendation: go with

Re: Elementary string-formatting

2008-01-13 Thread Odysseus
In article [EMAIL PROTECTED], Roberto Bonvallet [EMAIL PROTECTED] wrote: Put this at the beginning of your program: from __future__ import division This forces all divisions to yield floating points values: Thanks for the tip. May I assume the div operator will still behave as

Re: Elementary string-formatting

2008-01-13 Thread John Machin
On Jan 13, 8:43 pm, Odysseus [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Roberto Bonvallet [EMAIL PROTECTED] wrote: Put this at the beginning of your program: from __future__ import division This forces all divisions to yield floating points values: Thanks for the

Re: Elementary string-formatting

2008-01-13 Thread Odysseus
In article [EMAIL PROTECTED], Gary Herron [EMAIL PROTECTED] wrote: Odysseus wrote: snip print '%2u %6u %4.2f' % \ (i, wordcounts[i], 100.0 * wordcounts[i] / wordcounts[0]) Using 4.2 is the problem. The first digit (your 4) give the total number of characters to use for the

Re: Elementary string-formatting

2008-01-13 Thread Matt Nordhoff
Odysseus wrote: Hello, group: I've just begun some introductory tutorials in Python. Taking off from the word play exercise at http://www.greenteapress.com/thinkpython/html/book010.html#toc96 I've written a mini-program to tabulate the number of characters in each word in a file. Once

Elementary string-formatting

2008-01-12 Thread Odysseus
Hello, group: I've just begun some introductory tutorials in Python. Taking off from the word play exercise at http://www.greenteapress.com/thinkpython/html/book010.html#toc96 I've written a mini-program to tabulate the number of characters in each word in a file. Once the data have been

Re: Elementary string-formatting

2008-01-12 Thread Gary Herron
Odysseus wrote: Hello, group: I've just begun some introductory tutorials in Python. Taking off from the word play exercise at http://www.greenteapress.com/thinkpython/html/book010.html#toc96 I've written a mini-program to tabulate the number of characters in each word in a file. Once the

Re: Elementary string-formatting

2008-01-12 Thread John Machin
On Jan 13, 3:15 pm, Odysseus [EMAIL PROTECTED] wrote: [snip] P.S. Is there a preferable technique for forcing floating-point division of two integers to that used above, multiplying by 100.0 first? What about if I just wanted a ratio: is float(n / m) better than 1.0 * n / m? Odysseus You

Re: Elementary string-formatting

2008-01-12 Thread Roberto Bonvallet
On Jan 12, 10:15 pm, Odysseus [EMAIL PROTECTED] wrote: P.S. Is there a preferable technique for forcing floating-point division of two integers to that used above, multiplying by 100.0 first? Put this at the beginning of your program: from __future__ import division This forces all

Re: simple string formatting question

2007-12-14 Thread Bruno Desthuilliers
Neal Becker a écrit : I have a list of strings (sys.argv actually). I want to print them as a space-delimited string (actually, the same way they went into the command line, so I can cut and paste) So if I run my program like: ./my_prog a b c d I want it to print: './my_prog' 'a' 'b'

simple string formatting question

2007-12-14 Thread Neal Becker
I have a list of strings (sys.argv actually). I want to print them as a space-delimited string (actually, the same way they went into the command line, so I can cut and paste) So if I run my program like: ./my_prog a b c d I want it to print: './my_prog' 'a' 'b' 'c' 'd' Just print sys.argv

Re: simple string formatting question

2007-12-14 Thread Gary Herron
Neal Becker wrote: I have a list of strings (sys.argv actually). I want to print them as a space-delimited string (actually, the same way they went into the command line, so I can cut and paste) So if I run my program like: ./my_prog a b c d I want it to print: './my_prog' 'a' 'b' 'c'

Re: simple string formatting question

2007-12-14 Thread Neil Cerutti
On 2007-12-14, Neal Becker [EMAIL PROTECTED] wrote: I have a list of strings (sys.argv actually). I want to print them as a space-delimited string (actually, the same way they went into the command line, so I can cut and paste) So if I run my program like: ./my_prog a b c d I want it to

Re: String formatting with %s

2007-12-03 Thread Tim Chase
dictionary-key/value syntax), you can do something like: number = lambda x: dict((str(i+1), v) for (i,v) in enumerate(x)) %(2)s and %(1)s % number([A, B]) Whoa - that'll take me a little while to figure out, but it looks intriguing! It basically just returns a dictionary that maps your

String formatting with %s

2007-12-02 Thread Donn Ingle
Hi, I'm sure I one read somewhere that there is a simple way to set the order of replacements withing a string *without* using a dictionary. What I mean is: s = %s and %s % ( A, B ) print s A and B Now, is there something quick like: s = %s/2 and %s/1 % ( A, B ) print s B and A ? I know

Re: String formatting with %s

2007-12-02 Thread Mel
Donn Ingle wrote: Now, is there something quick like: s = %s/2 and %s/1 % ( A, B ) print s B and A ? GNU glibc printf accepts a format string: printf (%2$s and %1$s, A, B); to produce what you want -- but not Python, AFAIK. Mel. --

Re: String formatting with %s

2007-12-02 Thread Donn Ingle
but not Python, AFAIK Damn! \d -- http://mail.python.org/mailman/listinfo/python-list

Re: String formatting with %s

2007-12-02 Thread MRAB
On Dec 2, 1:35 pm, Donn Ingle [EMAIL PROTECTED] wrote: Hi, I'm sure I one read somewhere that there is a simple way to set the order of replacements withing a string *without* using a dictionary. What I mean is: s = %s and %s % ( A, B ) print s A and B Now, is there something quick

Re: String formatting with %s

2007-12-02 Thread James Matthews
try to import printf using ctypes On Dec 2, 2007 7:49 PM, MRAB [EMAIL PROTECTED] wrote: On Dec 2, 1:35 pm, Donn Ingle [EMAIL PROTECTED] wrote: Hi, I'm sure I one read somewhere that there is a simple way to set the order of replacements withing a string *without* using a dictionary.

Re: String formatting with %s

2007-12-02 Thread Tim Chase
I'm sure I one read somewhere that there is a simple way to set the order of replacements withing a string *without* using a dictionary. What I mean is: s = %s and %s % ( A, B ) print s A and B Now, is there something quick like: s = %s/2 and %s/1 % ( A, B ) print s B and A ?

Re: String formatting with %s

2007-12-02 Thread Donn
dictionary-key/value syntax), you can do something like: number = lambda x: dict((str(i+1), v) for (i,v) in enumerate(x)) %(2)s and %(1)s % number([A, B]) Whoa - that'll take me a little while to figure out, but it looks intriguing! Tah. \d --

[issue1068] Documentation Updates for PEP 3101 string formatting

2007-08-31 Thread Talin
New submission from Talin: This patch contains documentation updates for the Python Library Reference pertaining to PEP 3101 Advanced String Formatting. -- components: Documentation files: docupdates.diff messages: 55526 nosy: talin severity: normal status: open title: Documentation

[issue1068] Documentation Updates for PEP 3101 string formatting

2007-08-31 Thread Georg Brandl
Georg Brandl added the comment: Thanks! Committed as part of rev. 57829. -- assignee: - georg.brandl nosy: +georg.brandl resolution: - accepted status: open - closed __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1068

[issue1009] Implementation of PEP 3101, Advanced String Formatting

2007-08-25 Thread Eric V. Smith
Eric V. Smith added the comment: Closed, code was checked in revision 57444. -- versions: +Python 3.0 -Python 2.6 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1009 __

[issue1009] Implementation of PEP 3101, Advanced String Formatting

2007-08-25 Thread Eric V. Smith
Eric V. Smith added the comment: I tried to close it, without success. Possible tracker issue, I'll investigate. It should be closed! __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1009 __

[issue1009] Implementation of PEP 3101, Advanced String Formatting

2007-08-23 Thread Eric V. Smith
Changes by Eric V. Smith: -- versions: +Python 2.6 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1009 __ ___ Python-bugs-list mailing list Unsubscribe:

[ python-Bugs-1778207 ] rounding inconsisntency using string formatting

2007-08-22 Thread SourceForge.net
inconsisntency using string formatting Initial Comment: Sirs: Using python to generate a text file for transfer of data between systems, I seem to be getting inconsistent rounding results using a text formatting string Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32

[ python-Bugs-1778207 ] rounding inconsisntency using string formatting

2007-08-20 Thread SourceForge.net
: rounding inconsisntency using string formatting Initial Comment: Sirs: Using python to generate a text file for transfer of data between systems, I seem to be getting inconsistent rounding results using a text formatting string Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel

[ python-Bugs-1778207 ] rounding inconsisntency using string formatting

2007-08-20 Thread SourceForge.net
: rounding inconsisntency using string formatting Initial Comment: Sirs: Using python to generate a text file for transfer of data between systems, I seem to be getting inconsistent rounding results using a text formatting string Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel

Re: String formatting for complex writing systems

2007-07-02 Thread Andy
Thanks guys! I've used the HTML and the unicodedata suggestions, each on a different report. These worked nicely! Andy -- http://mail.python.org/mailman/listinfo/python-list

String formatting for complex writing systems

2007-06-27 Thread Andy
Hi guys, I'm writing a piece of software for some Thai friend. At the end it is supposed to print on paper some report with tables of text and numbers. When I test it in English, the columns are aligned nicely, but when he tests it with Thai data, the columns are all crooked. The problem here

Re: String formatting for complex writing systems

2007-06-27 Thread Gabriel Genellina
En Wed, 27 Jun 2007 04:20:52 -0300, Andy [EMAIL PROTECTED] escribió: I'm writing a piece of software for some Thai friend. At the end it is supposed to print on paper some report with tables of text and numbers. When I test it in English, the columns are aligned nicely, but when he tests it

Re: String formatting for complex writing systems

2007-06-27 Thread Leo Kislov
On Jun 27, 12:20 am, Andy [EMAIL PROTECTED] wrote: Hi guys, I'm writing a piece of software for some Thai friend.  At the end it is supposed to print on paper some report with tables of text and numbers.  When I test it in English, the columns are aligned nicely, but when he tests it with

Re: String formatting for complex writing systems

2007-06-27 Thread Leo Kislov
On Jun 27, 3:10 am, Leo Kislov [EMAIL PROTECTED] wrote: On Jun 27, 12:20 am, Andy [EMAIL PROTECTED] wrote: Hi guys, I'm writing a piece of software for some Thai friend.  At the end it is supposed to print on paper some report with tables of text and numbers.  When I test it in English,

String formatting with fixed width

2007-03-16 Thread Alexander Eisenhuth
Hello alltogether, is it possible to format stings with fixed width of let's say 7 character. T need a floating point with 3 chars before dot, padded with ' ' and 3 chars after dot, padded with '0'. Followingh is my approach f = 21.1 s = %.03f % f s '21.100' But there are missing ' '.

String formatting with fixed width

2007-03-16 Thread Alexander Eisenhuth
Hello alltogether, is it possible to format stings with fixed width of let's say 7 character. T need a floating point with 3 chars before dot, padded with ' ' and 3 chars after dot, padded with '0'. Followingh is my approach f = 21.1 s = %.03f % f s '21.100' But there are missing ' '.

Re: String formatting with fixed width

2007-03-16 Thread Steve Holden
Alexander Eisenhuth wrote: Hello alltogether, is it possible to format stings with fixed width of let's say 7 character. T need a floating point with 3 chars before dot, padded with ' ' and 3 chars after dot, padded with '0'. Followingh is my approach f = 21.1 s = %.03f % f s

Re: String formatting with fixed width

2007-03-16 Thread Jon Clements
On 16 Mar, 13:20, Alexander Eisenhuth [EMAIL PROTECTED] wrote: Hello alltogether, is it possible to format stings with fixed width of let's say 7 character. T need a floating point with 3 chars before dot, padded with ' ' and 3 chars after dot, padded with '0'. Followingh is my approach

Re: String formatting with fixed width

2007-03-16 Thread Steve Holden
Steve Holden wrote: Alexander Eisenhuth wrote: Hello alltogether, is it possible to format stings with fixed width of let's say 7 character. T need a floating point with 3 chars before dot, padded with ' ' and 3 chars after dot, padded with '0'. Followingh is my approach f = 21.1

Re: String formatting with fixed width

2007-03-16 Thread Alexander Eisenhuth
Thanks for your fast reply. I'm fine with your %7.03f solution. (negatives are not significant) Alexander Eisenhuth schrieb: Hello alltogether, is it possible to format stings with fixed width of let's say 7 character. T need a floating point with 3 chars before dot, padded with ' '

string formatting: engineering notation

2007-03-14 Thread Darren Dale
Does anyone know if it is possible to represent a number as a string with engineering notation (like scientific notation, but with 10 raised to multiples of 3: 120e3, 12e-6, etc.). I know this is possible with the decimal.Decimal class, but repeatedly instantiating Decimals is inefficient for my

Re: string formatting: engineering notation

2007-03-14 Thread Steve Holden
Darren Dale wrote: Does anyone know if it is possible to represent a number as a string with engineering notation (like scientific notation, but with 10 raised to multiples of 3: 120e3, 12e-6, etc.). I know this is possible with the decimal.Decimal class, but repeatedly instantiating Decimals

Re: string formatting: engineering notation

2007-03-14 Thread Darren Dale
Steve Holden wrote: Darren Dale wrote: Does anyone know if it is possible to represent a number as a string with engineering notation (like scientific notation, but with 10 raised to multiples of 3: 120e3, 12e-6, etc.). I know this is possible with the decimal.Decimal class, but repeatedly

Re: string formatting: engineering notation

2007-03-14 Thread Grant Edwards
On 2007-03-14, Steve Holden [EMAIL PROTECTED] wrote: Darren Dale wrote: Does anyone know if it is possible to represent a number as a string with engineering notation (like scientific notation, but with 10 raised to multiples of 3: 120e3, 12e-6, etc.). I know this is possible with the

Re: string formatting: engineering notation

2007-03-14 Thread Jorge Godoy
Steve Holden [EMAIL PROTECTED] writes: Darren Dale wrote: Does anyone know if it is possible to represent a number as a string with engineering notation (like scientific notation, but with 10 raised to multiples of 3: 120e3, 12e-6, etc.). I know this is possible with the decimal.Decimal

Re: string formatting: engineering notation

2007-03-14 Thread attn . steven . kuo
On Mar 14, 1:14 pm, Darren Dale [EMAIL PROTECTED] wrote: Does anyone know if it is possible to represent a number as a string with engineering notation (like scientific notation, but with 10 raised to multiples of 3: 120e3, 12e-6, etc.). I know this is possible with the decimal.Decimal class,

Re: string formatting: engineering notation

2007-03-14 Thread Darren Dale
[EMAIL PROTECTED] wrote: On Mar 14, 1:14 pm, Darren Dale [EMAIL PROTECTED] wrote: Does anyone know if it is possible to represent a number as a string with engineering notation (like scientific notation, but with 10 raised to multiples of 3: 120e3, 12e-6, etc.). I know this is possible with

Re: Tkinter Listbox string formatting question - how to kill a dancingsnake ?

2006-11-02 Thread Hendrik van Rooyen
Fredrik Lundh [EMAIL PROTECTED] wrote: lots of stuff to for me to download and read up In the meantime, I have produced this evil hack, that takes advantage of the difference in pixel widths between the space, and either the fullstop or the single quote... It will only work if you have quite

Re: Tkinter Listbox string formatting question - how to kill a dancing snake ?

2006-10-31 Thread Fredrik Lundh
Hendrik van Rooyen wrote: Is there a way to format this so it will line up with *any* font ? I would prefer not to give up and use a fixed width font - it looks so teletypish... sounds like contradicting requirements to me. instead of trying to force the listbox to behave like a

Re: Tkinter Listbox string formatting question - how to kill a dancingsnake ?

2006-10-31 Thread Hendrik van Rooyen
Fredrik Lundh [EMAIL PROTECTED] wrote: instead of trying to force the listbox to behave like a multicolumn widget, maybe you could switch to another widget? some alternatives include a Text widget (you have to roll your own selection logic) I _really_ don't feel strong enough for

Re: Tkinter Listbox string formatting question - how to kill adancingsnake ?

2006-10-31 Thread Hendrik van Rooyen
Hendrik van Rooyen [EMAIL PROTECTED] wrote: Fredrik Lundh [EMAIL PROTECTED] wrote: instead of trying to force the listbox to behave like a multicolumn widget, maybe you could switch to another widget? some alternatives include a Text widget (you have to roll your own selection

Tkinter Listbox string formatting question - how to kill a dancing snake ?

2006-10-30 Thread Hendrik van Rooyen
I am populating a listbox from a directory that looks like this: variable_dict = {funny_long_or_short_variable_name_as_key: (2,45),.. the tuple represents a card, line pair. medf is a font object and a forward reference here. I write: for x in variable_dict: txt = x while

Re: Reverse string-formatting (maybe?)

2006-10-15 Thread Dustan
Peter Otten wrote: Dustan wrote: Is there any builtin function or module with a function similar to my made-up, not-written deformat function as follows? I can't imagine it would be too easy to write, but possible... template = 'I am %s, and he %s last %s.' values = ('coding',

Re: Reverse string-formatting (maybe?)

2006-10-15 Thread Tim Chase
My template outside of the '%s' characters contains only commas and spaces, and within, neither commas nor spaces. Given that information, is there any reason it might not work properly? Given this new (key) information along with the assumption that you're doing straight string replacement

Re: Reverse string-formatting (maybe?)

2006-10-15 Thread Dustan
Tim Chase wrote: My template outside of the '%s' characters contains only commas and spaces, and within, neither commas nor spaces. Given that information, is there any reason it might not work properly? Given this new (key) information along with the assumption that you're doing

Re: Reverse string-formatting (maybe?)

2006-10-15 Thread Dustan
Dustan wrote: Tim Chase wrote: My template outside of the '%s' characters contains only commas and spaces, and within, neither commas nor spaces. Given that information, is there any reason it might not work properly? Given this new (key) information along with the assumption that

Re: Reverse string-formatting (maybe?)

2006-10-15 Thread Dustan
Dustan wrote: Dustan wrote: Tim Chase wrote: My template outside of the '%s' characters contains only commas and spaces, and within, neither commas nor spaces. Given that information, is there any reason it might not work properly? Given this new (key) information along with

Re: Reverse string-formatting (maybe?)

2006-10-15 Thread Dan Sommers
On 14 Oct 2006 05:35:02 -0700, Dustan [EMAIL PROTECTED] wrote: Is there any builtin function or module with a function similar to my made-up, not-written deformat function as follows? I can't imagine it would be too easy to write, but possible... [ snip ] Any input? I've looked through the

Re: Reverse string-formatting (maybe?)

2006-10-15 Thread Tim Chase
template = '%s, %s, %s' values = ('Tom', 'Dick', 'Harry') formatted = template % values import re unformat_string = template.replace('%s', '([^, ]+)') unformatter = re.compile(unformat_string) extracted_values = unformatter.search(formatted).groups() using '[^, ]+' to mean

Re: Reverse string-formatting (maybe?)

2006-10-15 Thread Dustan
Only you know what anomalies will be found in your data-sets. If you know/assert that -the only stuff in the formatting string is one set of characters -that stuff in the replacement-values can never include any of your format-string characters -that you're not using funky

Reverse string-formatting (maybe?)

2006-10-14 Thread Dustan
Is there any builtin function or module with a function similar to my made-up, not-written deformat function as follows? I can't imagine it would be too easy to write, but possible... template = 'I am %s, and he %s last %s.' values = ('coding', coded', 'week') formatted = template % values

Re: Reverse string-formatting (maybe?)

2006-10-14 Thread Tim Chase
template = 'I am %s, and he %s last %s.' values = ('coding', coded', 'week') formatted = template % values formatted 'I am coding, and he coded last week.' deformat(formatted, template) ('coding', 'coded', 'week') expanded (for better visual): deformat('I am coding, and he coded last

<    4   5   6   7   8   9   10   >