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

Nick Coghlan ncoghlan at gmail.com
Thu Oct 1 23:15:14 CEST 2009

Glenn Linderman wrote:
> 1) Both the format message and all the parameters are supplied in a
> single API call.  This is really a foolish API, because
>    def API( fmt, p1, p2, p3 ):
>     str = fmt % (p1, p2, p3)
> could have just as easily been documented originally as
>    def API( str ):
> where the user is welcome to supply a string such as
>    API( fmt % (p1, p2, p3 ))
> and if done this way, the conversion to .format is obvious... and all
> under the users control.

The lazy APIs actually make a lot of sense, particularly when there is a
chance that the function being called may be able to avoid the
formatting call altogether.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list