[Python-3000] Addition to PEP 3101

Patrick Maupin pmaupin at gmail.com
Mon Apr 30 21:56:12 CEST 2007

On 4/30/07, James Thiele <python3now at gmail.com> wrote:
> For PEP: 3101  - Advanced String Formatting - I would like to suggest
> the following additions.
> First, that an additional pair of forms be added to format strings so
> that callable objects could be used as parameters to the format string
> method:
> {0()} for positional arguments and
> {keyword()} for keyword parameters.
> The proposal is that if the format string had this form that the
> format string method would treat the parameter as a callable and use
> the value of the return for the formatting.
> The second addition would be the forms
> {0.method()} and
> {keyword.method()}
> where "method" is a method of the object.
> This would allow things such as:
> "I want to shout '{0.upper()}'".format("hello world")
> which would yield:
>  "I want to shout 'HELLO WORLD'"

Method calls are deliberately disallowed by the PEP, so that the
implementation has some hope of being securable.


More information about the Python-3000 mailing list