[Python-Dev] Replacement for print in Python 3.0

Steve Holden steve at holdenweb.com
Tue Sep 6 22:32:59 CEST 2005


Guido van Rossum wrote:
> On 9/6/05, Barry Warsaw <barry at python.org> wrote:
> 
>>printf('$1 forgot to frobnicate the $2!\n', username, file.name,
>>       to=sys.stderr)
>>
>>While that's a little less self-descriptive for a translator to deal
>>with (who would only see the string, not the call site), it certainly
>>looks nicer for a non-i18n application, and could certainly work for an
>>i18n app too.  It's a neat idea worth exploring.
> 
> 
> Is it worth doing this and completely dropping the %-based formats in
> Py3k? (Just asking -- it might be if we can get people to get over the
> shock of $ becoming first class ;-).
> 
> 
>>Also, I think you posted in a separate article a syntactic proposal for
>>including detailed formating in $-vars.  ${varname:fmt} where 'varname'
>>could be an identifier a la PEP 292 or possibly a positional argument.
> 
> 
> +1
> 
> I proposed ${varname%fmt} earlier but it prevents you to extend the
> varname syntax to arbitrary expressions, which I think is an extension
> that will get lots of requests.
> 
I would anticipate security issues with allowing general expressions: 
you are effectively allowing access to eval(). If a naiive programmer 
were to use unverified input as a format string unpleasant things could 
happen ... your call, but it seems dangerous to me. Remember C's printf 
has been the source of some very dangerous errors.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC             http://www.holdenweb.com/



More information about the Python-Dev mailing list