[Python-Dev] transitioning from % to {} formatting

Glenn Linderman v+python at g.nevcal.com
Fri Oct 9 01:13:13 CEST 2009


On approximately 10/8/2009 7:24 AM, came the following characters from 
the keyboard of Eric Smith:
> Vinay Sajip wrote:
>> BTW I sent Eric a private mail re. the "0o" versus "0" issue, to see 
>> if it was
>> worth raising an enhancement request on the bug tracker using "O" to 
>> generate
>> compatible rendering for octals.
> 
> I didn't get your message, could you resend?.
> 
> I was thinking the same thing, but it seems like a transition step. I'd 
> rather not keep such backward compatibility hacks (if you will) around 
> for the long haul.  How about a flag (maybe '*') at the start of the 
> format specification which says "operate in backward compatibility 
> mode"? We could document it as being only useful for the % to {} 
> translator, and promise to remove it at some point in the future. Either 
> actually deprecate it or just promise to deprecate it in the future.


Seems like the ability for Python {} formatting to be able to match not 
only old Python % formatting output, but also output created by C's 
sprintf, and other numeric formatting systems, make this particular 
feature useful in more scenarios than a "backward compatibility hack".

If you want to replace a C program that produces parsed output in a 
given format, and that given format includes leading-0-octal numbers, 
then it would be good to have the capability in Python .format, even 
though Python itself uses 0o prefix.

Similar arguments may apply anywhere else that sprintf produces 
something that .format cannot currently produce.


-- 
Glenn -- http://nevcal.com/
===========================
A protocol is complete when there is nothing left to remove.
-- Stuart Cheshire, Apple Computer, regarding Zero Configuration Networking


More information about the Python-Dev mailing list